good chemistry is complicated,
and a little bit messy -LW
NVM - was Win32::GUI and widget focus after window focus changeby mrider (Sexton)
|on Aug 29, 2012 at 17:03 UTC||Need Help??|
mrider has asked for the
wisdom of the Perl Monks concerning the following question:
I've tried Googling for this as well as reading through the Win32-GUI documentation, but haven't found anything. Here's my issue: I have a Win32::GUI dialog with a few widgets. When I Alt Tab away from the dialog and then Alt Tab back, the widget which previously had focus loses it. Additionally, it appears as if nothing inside the dialog has focus, and that focus can't be regained directly from the keyboard without an accelerator (i.e. multiple presses of "Tab" does not move back to a widget).
I'm considering having a variable with dialog global scope that stores a reference to a widget, and then I can add a event handler in each widget that puts itself into that variable when a given widget gains focus. I could then have a focus listener on the dialog which restores focus to the widget as reflected by the variable when the dialog itself regains focus.
But before I do all that, I want to see if there's something simple I'm missing. So basically is there a better way than storing the widget which previously had focus and then restoring it?
EDIT: I should add that to demonstrate my problem, run the SSCCE, place the cursor inside the text field, Alt-Tab away from the dialog, and then Alt-Tab back. See how the field does not have focus? Also see how multiple presses of Tab will not put it back?
EDIT 2: Well, don't I feel dumb. From Win32::GUI::Tutorial::Part3 keyboard handling:
"To make the tab keys work as expected, you need to add the -tabstop => 1 option to your controls. The tab keys move the focus between the controls with the -tabstop option set. Other controls will be ignored when tabbing."