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
Developer
Posts: 90
Registered: ‎09-07-2010
My Device: Not Specified
Accepted Solution

Moving focus among multiple fields

[ Edited ]

Hello, i have a screen like that:

 

Dibujo.PNG

 

 

Just don't worry about the incorrect layout: i would like to know, how can i move foccus properly among the buttons? Behavior when i press left and right is not the desired one. I have been looking some posts related and i've only seen that i have to override the moveFocus method, but i just wanted to know if there's any easier way to do it.

 

Thanks in advance.

Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: Moving focus among multiple fields

Overriding moveFocus (both signatures), and perhaps keyChar, in the manager that contains your buttons is the way to go. Writing your own logic allows you exact control over the user interface, and it isn't particularly hard.




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Developer
Posts: 90
Registered: ‎09-07-2010
My Device: Not Specified

Re: Moving focus among multiple fields

Thanks for your help, Ted.

 

What do you mean with bothSignatures and keyChar?

 

I also know there's some issue with the trackwheel constants, do you know something about that?

Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: Moving focus among multiple fields

You should probably override both

int moveFocus(int amount, int status, int time)

and

void moveFocus(int x, int y, int status, int time)

I don't know about an issue with trackwheel constants. The only thing I can think of is that you are unlikely to run into a trackwheel event, since most devices these days have a 4-way input device (ball or pad).

 

As to keyChar, several managers trap ENTER or SPACE and react by moving the focus. You might want to do the same thing for those or for shortcut keys.




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Developer
Posts: 114
Registered: ‎04-28-2010
My Device: Storm 9530
My Carrier: Telus

Re: Moving focus among multiple fields

 What I believe your trying to achieve is:

           For each icon you have a 'predefined' path if the user clicks to the left, right, top, or bottom.

           Example. Eventos can either go to noficacinnes or to buscar and nothing else (top and bottom do nothing).

 

I believe the issue you have is quite simple to solve. If I'm not correct I believe the order in which the icons are being focused on are in the same order of them being added to the manager. If this is true I think you should create an FSM (final state machine) for which determines the users input and moves the focus of the icons. The states are defined as the icons and the 'transition conditions' represent the ability to move focus to another state.

 

My algorithm to this problem is:

            I.) Every event dealing with the optical pad or trackpad, determine the direction.

            ii.) Determine which icon is within focus within your Manager

            iii.) Cross reference with your FSM to determine if the 'transition condition' holds to move to another icon (new state)

            iv.) If the direction is invalid stay the current icon remains in focus or if it is...

                  Change the state of the FSM to the icon towards that direction and tell your manager(or screen.. can't remember for sure) to move the focus to this icon.

 

PS Icon can be a button or label field or text field.

 

Sorry, this is a long read but I believe it'll help you for the situation that I believe your in. If not this is not the desired focus movement or I'm just slightly off or even have questions about the FSM, message me Smiley Happy

 

Mitchell Romanuik. 

Developer
Posts: 713
Registered: ‎05-31-2010
My Device: 8520
My Carrier: Movistar

Re: Moving focus among multiple fields

You can override the navigationMovement method() of the manager that contains the fields...

Developer
Posts: 90
Registered: ‎09-07-2010
My Device: Not Specified

Re: Moving focus among multiple fields

Thank you guys for all your answers, finally i did it overriding the navigationMovement method, controllind dx and dy momvents and the foccused field at every moment. It works perfectly now, as i want.

 

Thanks again!