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
Contributor
maheshqtech
Posts: 43
Registered: ‎11-24-2011
My Device: Perl

want to maintane the focus on last click buttons

Hi, I developed a BB application on which I create many custom buttons , on click of this it will show the respective pages

 

when I press the back button it will reach on the main screen where the buttons are drawn & it will show the focus on first button if I click on the fifth button then the focus is should be on fifth button when I come back on the main Screen where the buttons are drawn

 

If any code thanks for it

 

 

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: want to maintain the focus on last click buttons

If you use the usual BlackBerry process of pushing the new screen and then when it is finished, that screen is popped exposing the original screen, this will happen automatically. 

 

If you recreate the screen on return, you will have to remember which screen you last invoked and setFocus on the associated Button.  Aside from the

<field>.setFocus();

there is nothing "magic" in this code.

 

I would try to us the push/pop mechanism if you can because that is how users expect the BlackBerry to work.   

Contributor
maheshqtech
Posts: 43
Registered: ‎11-24-2011
My Device: Perl

Re: want to maintain the focus on last click buttons

Can any one give me short code for this...........

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: want to maintain the focus on last click buttons

By this, do you mean pushing and popping screens?  I think most of the RIM supplied samples do it.

Contributor
maheshqtech
Posts: 43
Registered: ‎11-24-2011
My Device: Perl

Re: want to maintain the focus on last click buttons

on my application i use so many custom buttons and when come back to main screen I read xml file and for come back i use the

UiApplication.getUiApplication().pushScreen(objMenus);  syntax because of this the focus is set to the first button I want it set to that button which i press last time if any code plz sent me

 

Thanks

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: want to maintain the focus on last click buttons

Before we try to create a workaround to solve your specific problem, we should make sure that you are in fact doing it correctly. 

 

The process is typically.

 

1) Create and push screen A

2) user clicks on something on Screen A, so application creates and pushes Screen B

At this point the user is seeing Screen B.  But in fact Screen A is underneath Screen B and so hidden

3) User closes Screen B and it is popped of the display stack, now the user can see Screen A

At this point Screen A is in the same state as it was when the user clicked to get Screen B.  The button pressed to go to Screen B remains focused as it was. 

 

So why doesn't this process work for you?