|Re: How to set the focus on a specific field? [message #947640 is a reply to message #947588]
||Wed, 17 October 2012 09:19
| Beat Schwarzentrub
Registered: November 2010
A. Del. wrote on Wed, 17 October 2012 04:13|
I 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.
Powered by FUDForum
. Page generated in 0.02180 seconds