How to set the focus on a specific field? [message #932602] |
Thu, 04 October 2012 04:59  |
Eclipse User |
|
|
|
Is there a way to set the focus on a specific field?
For instance, when a validation returns an error, I would like to set the focus on the field the user has to correct, so the user could start typing right away.
I use the SWT UI rendering technology
Thanks for your help.
|
|
|
|
|
|
Re: How to set the focus on a specific field? [message #947640 is a reply to message #947588] |
Wed, 17 October 2012 05:19   |
Eclipse User |
|
|
|
A. Del. wrote on Wed, 17 October 2012 04:13I tried to use the method requestFocus() on IFormField. Sometimes it works and somtimes it doesn't.
Like the name states, the method requestFocus() does not _set_ the focus. It's a _request_ to the UI layer to set the focus. This request may be denied or ignored by the UI layer for several reasons. The field has to be ready and visible on screen. Or, for example, while a message box is shown, the focus cannot be set to a field on a dialog in the background.
The Scout UI layer delegates the request to the underlying UI field (e.g. a JTextField in Swing). Note that this does still not guarantee that the focus is now on the desired field, because the UI itself may deny the request for some reason.
If the behaviour is "random", then you see to have run into a race condition (sometimes the UI is ready, sometimes it's not). Try to synchronize your focus request, e.g. by wrapping it into a ClientSyncJob.
Regards,
Beat
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05169 seconds