BlackBerry Forums Support Community

Closed Thread
LinkBack Thread Tools
Old 04-20-2009, 03:31 PM   #1 (permalink)
Knows Where the Search Button Is
Join Date: Apr 2009
Model: 7100t
Carrier: verizon
Posts: 21
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Set focus to the most left field of a Horizontal field manager

Please Login to Remove!


I have several labelfields in a horizontalfieldmanager.
When I scrool up to the HFM (so i'm coming from the bottom of the screen) the focus gets to the most right element.

How can i get it to the right?

It tried that but got a stack overflow (if someone want to explain why that will be also nice)

protected void onFocus(int direction) {
Old 04-20-2009, 07:49 PM   #2 (permalink)
BlackBerry Extraordinaire
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts

Your code example above will cause a stack overflow because calling setFocus() will result in yet another (recursive) call to onFocus(), which again calls setFocus(), and so on, forever. Each call pushes the return address on the stack, which is of finite size and eventually overflows.
Old 05-07-2009, 05:08 AM   #3 (permalink)
New Member
Join Date: May 2009
Model: 8830
Carrier: Cingular
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts

AFAIU you want to set focus to the first field despite navigation direction. Generally speaking if you want to implement custom focusing order in your manager you have to override nextFocus method and implement custom logic there. However in your simple case you can cheat HFM saying that it is focused by navigation from previous control despite actual direction. Something like this should work for you:
protected void onFocus(int direction)
	super.onFocus(1);	//cheat HFM: set direction to forward

Last edited by SergGr : 05-07-2009 at 05:10 AM.

Copyright 2004-2016
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.