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: 156
Registered: ‎02-18-2009
My Device: Not Specified

How can I remove the focus from my field programatically?

I have a field (which extends from BasicEditField) and when the user clicks the field (using touchEvent) I would like to remove the focus from the field and focus the next focussable field.

 

Is it possible for a field to programtically loose focus from within the fields even handlers? If so how? I have tried multiple methods but still haven't found the right solution.

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: How can I remove the focus from my field programatically?

onFocus in particular field.. set the focus to some other field.

Use Search. "Accept Solution" If the problem is resolved.
Highlighted
Developer
Posts: 183
Registered: ‎12-17-2008
My Device: 8320

Re: How can I remove the focus from my field programatically?

Try with below:

 

public void onUnfocus()
    {
        super.onUnfocus();
        setBitmap(bm1);
    }

kums

******************************

Press kudos which the post help you
Please mark posts as solved if you got a solution
Developer
Posts: 156
Registered: ‎02-18-2009
My Device: Not Specified

Re: How can I remove the focus from my field programatically?

But the event handler handles the event in the Field itself. The field has no knowledge of other fields.

 

I can iterate through all fields of the parent but there must be an easier way I guess?

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: How can I remove the focus from my field programatically?

That left to your design, how your one filed knows the other field.

Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 16,846
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How can I remove the focus from my field programatically?

i would suggest to handle this in the manager. overwrite moveFocus
----------------------------------------------------------
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
Developer
Posts: 183
Registered: ‎12-17-2008
My Device: 8320

Re: How can I remove the focus from my field programatically?

Try to use FieldChangeListener! also see TouchEvent Class
kums

******************************

Press kudos which the post help you
Please mark posts as solved if you got a solution
Developer
Posts: 156
Registered: ‎02-18-2009
My Device: Not Specified

Re: How can I remove the focus from my field programatically?


simon_hain wrote:
i would suggest to handle this in the manager. overwrite moveFocus

I was hoping that that was some method like releaseFocus that you can use from within a field. It's strange that there is a setFocus method but no releaseFocus method. I now have to 'tell' the manager that 'I' (read the field) no longer need the focus.

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

Re: How can I remove the focus from my field programatically?

[ Edited ]

If you don't have focus and don't want it at present, then just return false to isFocusable().

 

If you currently have focus and want the focus to move, then you need to decide where it is to go.  If you have another Field, then this is easy, you can just use Field.setFocus().  If you don't know where it is to go, let us know, and also the minimum level of OS your are targeting.  I think I wrote some code to move the focus at one stage, I might be able to dig it out. 

 

Edit: Apologies, just realised I've basically repeated what Simon had already said. 

Message Edited by peter_strange on 09-24-2009 01:44 PM
Developer
Posts: 156
Registered: ‎02-18-2009
My Device: Not Specified

Re: How can I remove the focus from my field programatically?


peter_strange wrote:

 If you don't know where it is to go, let us know, and also the minimum level of OS your are targeting.  I think I wrote some code to move the focus at one stage, I might be able to dig it out.


I can fire an event and catch it in the manager and let the manager focus the next field but I prefer to keep the solution field centric (ie. if the field decides that it has enough information it can release the focus and let the manager decide what the next focus is). I guess there isn't something similar to setFocus so I will 'ask' the manager to shift the focus