Restoring focus to the element after closing dialog box

67 views
Skip to first unread message

prads

unread,
Jan 6, 2009, 3:21:24 AM1/6/09
to Google Web Toolkit
Hi all,

As per a requirement in my application, I need to set the focus on the
element for which a dialog box was opened, after the latter is closed.
So, there could be a row in a table for which a dialog box could be
opened by the user. After the user closes the dialog box, I need to
restore the focus back to the element. We have used JSNI for setting
the focus back on the element and this part seems to work correct.

The problem is in figuring out the element on which the focus is to be
restored. I can pass the element to the customized show method of the
dialog box (overriding it in a class which extends DialogBox) and use
it when the hide method is called. Somehow, I dont find this solution
very convincing. So, if there is something in GWT which support the
functionality which I wish to achieve, it would be great.

Please provide me ur suggestions ASAP.

Isaac Truett

unread,
Jan 6, 2009, 2:00:05 PM1/6/09
to Google-We...@googlegroups.com
What's wrong with that solution? How would you do it without keeping
track of the element that had focus before the dialog opened?

prads

unread,
Jan 7, 2009, 10:46:56 PM1/7/09
to Google Web Toolkit
The thing is that the show/center method of the DialogBox is called
from many places in the application. And, I do not wish to make
changes in these many places (for implementing the solution mentioned
above) . So, I thought if we could figure out the element on whose
event the dialog box's show was invoked, it would be nice. Sounds a
bit far-fetched, but if there is some other way to accomplish this,
please suggest.

Reply all
Reply to author
Forward
0 new messages