09-24-2009 07:44 AM
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.
09-24-2009 08:08 AM
Try with below:
public void onUnfocus()
09-24-2009 08:10 AM
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?
09-24-2009 08:13 AM
09-24-2009 08:15 AM
09-24-2009 08:24 AM
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.
09-24-2009 08:29 AM - edited 09-24-2009 08:44 AM
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.
09-24-2009 09:09 AM
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