I want to make a text-control that uses a model object that
receives the value of the text-control when either the focus
is lost or when the enter key is pressed.
I made my own class derived from wx.TextCtrl that binds the
events EVT_KILL_FOCUS and EVT_TEXT_ENTER (requires style
TE_PROCESS_ENTER).
In the event-handlers for these events I copy the value from the
control to the model.
Unfortunately when I use TE_PROCESS_ENTER, the enter key does not
switch the focus to the next text-control. I removed the
TE_PROCESS_ENTER
style. The result is that pressing enter switches the focus to the
next control and the event-handler to commit the value is still
called
(not in EVT_TEXT_ENTER but in EVT_KILL_FOCUS).
This works when I use more than one control. But when I use only one
control, the enter key does not switch focus and the EVT_TEXT_ENTER
is also missing.
Does anybody know a way to catch the enter-key in an event-handler AND
to
allow the enter-key to switch the focus to the next control ?
I am using wx-2.8.10.1, python-2.6.4, windows vista sp2
You need to handle the navigation to the next control in your text
enter handler when you are processing the enter key yourself
(TE_PROCESS_ENTER).
@see: wx.Window.Navigate
def OnEnter(self, evt):
evt.EventObject.Navigate() # move to next control
Cody
Thank you for your quick response, it works !
Erwin
HiI'm using wxpython '3.0.0.0' and python 2.7.8 32bit and i want to use this behabiour but it failsSo when I press the tab control the selection doesn't change.
I made the changes and it works fine for me!
--
You received this message because you are subscribed to a topic in the Google Groups "wxPython-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wxpython-users/ckx3pa3BWgk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.