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
yann247
Posts: 96
Registered: ‎03-06-2009
My Device: Not Specified
Accepted Solution

Put focus on the top of the screen

Hello,

 

I have a screen with several fields in a VerticalFieldManager.

 

I would like a focused field to be as much near the top of the screen as possible when I call setFocus on it.

Right now, the focused field is on the bottom of the screen (as if I scrolled down until I reached it).

I want it to be on the top of the screen.

 

How can I do that?

thanks

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Put focus on the top of the screen

call the setFocus() method on the field that you want to have the focus.

 

Please use plain text.
Developer
yann247
Posts: 96
Registered: ‎03-06-2009
My Device: Not Specified

Re: Put focus on the top of the screen

that's what I do but it doesn't put the focused field on the top of the screen, its at the bottom
Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Put focus on the top of the screen

Sorry, you've lost me.

 

If you want the last field at the bottom of the screen to be at the top of the screen, then you need to put it there.

 

Please use plain text.
Developer
yann247
Posts: 96
Registered: ‎03-06-2009
My Device: Not Specified

Re: Put focus on the top of the screen

Not sure you got what I meant.

I have a vertical field manager too big for the screen. I have a button at the top of the VFM.

 

When I press the button I want to "search" for a field. At the moment I use setfocus on my field, but when I do that the field is a the bottom of the screen, like this:

 

-------------------------

blabla1

blabla2

blabla3

blabla4

FOCUSEDFIELD

-------------------------

 

 

I want it to be like that:

----------------------

FOCUSEDFIELD

blabla5

blabla6

blabla7

-----------------------

 

How I can put it up more?

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Put focus on the top of the screen

Look at Manager.moveFocus()

 

 

 

Please use plain text.
Developer
yann247
Posts: 96
Registered: ‎03-06-2009
My Device: Not Specified

Re: Put focus on the top of the screen

I tried it but thats not what I need since I don't know how many field there is going to be below.

I really just want to dynamically select a field and "put" it at the top of the screen.

Please use plain text.
Developer
yann247
Posts: 96
Registered: ‎03-06-2009
My Device: Not Specified

Re: Put focus on the top of the screen

Solved it:

 

 

((TitleField)mgr.getField(0)).setFocus(); // scroll it to the bottom of the screen getScreen().scroll(Screen.DOWNWARD); // make it go up but focuses the bottom most element ((TitleField)mgr.getField(0)).setFocus(); // reset the focus to the field, now at the top

 

 

 

Please use plain text.