Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
Posts: 9
Registered: ‎01-06-2009
My Device: Not Specified

Restore the last focused field within a manager Manager.firstFocus(int)

Hi, I have a question concerning the focus restoration within a manager.

 

I have a screen with two managers and each one contains several fields. The first manager layout the field horizontaly and the second one layout the fields vertically. When the user scroll down when he is on the first manager, the focus will be passed to the second manager and to each field of the second manager (the opposite when the used scroll up). When the user scroll left/right while he is on the first manager, this will select each fields of the first manager laid out horizontally. 

 

When the focus is exchanged between the first and second manager, the focus within this manager will always be on the first field of this manager. Suppose the used is on the second field of the first manager and scroll down. This will change the focus to the first field of the second manager. When he scroll up, the focus will be on the first field of the first manager.I woudl like that the last focused field within a manager (the second field of the first manager in this above example) be restored when the manager is re focused.

 

I tried to keep the index of the last focused field within the manager and tried to restore that last focused field by using the Field.setFocus() method but this method seems to not work properly when the screen is already displayed.

 

I'm using the undocumented API Manager.firstFocus(int direction) and this works fine for me.

 

My questions:

1. Could you suggest a way to implement my "last focus restoration" requirement ?

2. Why the Manager.firstFocus(in) is not published ? is there another APi which does the same job ?

 

Best regards
Shan

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Restore the last focused field within a manager Manager.firstFocus(int)

You can call the setFocus method for the field you wish to move focus to.  This allows you to create a custom focus order and move focus between fields of your choice.

 

It is discouraged to use any methods not listed in the public JavaDocs.  These hidden methods could be changed or removed at any time.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 177
Registered: ‎01-21-2009
My Device: 9900
My Carrier: Vodafone

Re: Restore the last focused field within a manager Manager.firstFocus(int)

Hi Mark,

 

Always wondered what the reason is for this. Why not just hide those methods from the public net_rim_api class set? Also many developers make use of the handy dandy functions like Field.setPadding() to avoid having to write a custom manager or field. Please please please do not remove those. I've always found it odd for example that Font.derive( int style, int height, int units, int antialiasMode, int effect) is publicly documented but the Font.ANTIALIAS_* and Font.*_EFFECT constants are not. Any chance on officially documenting some of those hidden APIs?

Highlighted
BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Restore the last focused field within a manager Manager.firstFocus(int)

The auto complete in the newer BlackBerry JDE releases is "smarter" and shouldn't show these hidden methods.

 

I recommend posting the hidden methods you use to the Product Management board here:  http://supportforums.blackberry.com/rim/board?board.id=PM_Dev_Board

 

That way it'll get in front of the right set of eyes (and others can then add their support if the want).

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker