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
Regular Contributor
Posts: 59
Registered: ‎03-06-2012
My Device: 9700
My Carrier: airtel

start of app focus position

Hi All,

 

I am trying to get  a focus on a labelfield at the start of app usng the below code

 

public MyScreen() {
        screen = this;
      
        onUiEngineAttached(true);
    }

    protected void onUiEngineAttached(boolean attached) {
        if (attached) {
            label1.setFocus();
        }
    }

 

this gives the focus to the label on start of app but i also want the screen to be moved up starting from the focus,i have a list having labels say from 0 to 10 i am setting the focus on 9 on start of app ,the focus is set but the screen should start from the focus position how to handle this

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

Re: start of app focus position

Not trivial to do this.  You need to know what Managers you have and what position within the manager the LabelField is and then set the scroll appropriately.  The easy part is the setVerticalScroll, the hard part is knowing which Manager to set and to what value.

 

This Thread might help.

http://supportforums.blackberry.com/t5/Java-Development/How-to-get-the-Field-s-Exact-x-and-y-positio...

Highlighted
Regular Contributor
Posts: 59
Registered: ‎03-06-2012
My Device: 9700
My Carrier: airtel

Re: start of app focus position

any snippet as a demo ?
Developer
Posts: 17,012
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: start of app focus position

no. you can search the forum for posts that discussed this issue and there are several code snippets in them.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter