04-01-2009 11:48 AM
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
04-15-2009 10:56 AM
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.
04-15-2009 12:18 PM
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?
04-24-2009 01:58 PM
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?boar
That way it'll get in front of the right set of eyes (and others can then add their support if the want).