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
PIN: N/A
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!

Hello,

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)
thanks

Code:
protected void onFocus(int direction) {
this.getField(0).setFocus();
}
Offline  
Old 04-20-2009, 07:49 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

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.
Offline  
Old 05-07-2009, 05:08 AM   #3 (permalink)
New Member
 
Join Date: May 2009
Model: 8830
PIN: N/A
Carrier: Cingular
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

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:
Code:
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.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.