struggling to control tabbing thru controls

Hope someone can point me in the right direction.

Attached is a small program that demonstrates a problem I am having with capturing the tab key in a wx.ComboBox and wxChoice.

Essentially I have multiple controls on a form. I want the user to step thru each control and only enable the next control, once data has been selected.

If the user makes a mistake, they can push the reset button and start again start the form all over again.

— so far so good, but this is where the problem lies.

If the user is referred back to the first field, I would like them to be able to use the “tab” or the “enter” on the keyboard to accept the selection that is visible in the combobox or choice box.

I have the EVT_CHAR bound to the control, but it does seem to get fired (- or prehaps more accurately, doesn’t get picked up)

Any guidance would be appreciated.

Thanks.

Test Tab Order.py (2.66 KB)

Geoff Skerrett wrote:

Hope someone can point me in the right direction.
Attached is a small program that demonstrates a problem I am having with capturing the tab key in a wx.ComboBox and wxChoice.
Essentially I have multiple controls on a form. I want the user to step thru each control and only enable the next control, once data has been selected.
If the user makes a mistake, they can push the reset button and start again start the form all over again.
--- so far so good, but this is where the problem lies.
If the user is referred back to the first field, I would like them to be able to use the "tab" or the "enter" on the keyboard to accept the selection that is visible in the combobox or choice box.
I have the EVT_CHAR bound to the control, but it does seem to get fired (- or prehaps more accurately, doesn't get picked up)

Since EVT_CAHR is not a command event it does not propagate up to parent widgets, so you need to bind it directly to the controls that you want to receive it from. For example:

         self.cbx.Bind(wx.EVT_CHAR, self.on_chars)

instead of

         self.Bind(wx.EVT_CHAR, self.on_chars)

However you may still not be able to get char events for the Tab key as it is stolen for navigation events. You may be able to do what you want by watching for the navigation events or focus events and doing your stuff when they happen.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!