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
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 ?
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
···
On Wed, Dec 14, 2011 at 1:53 PM, ErwinP <hombre67@gmx.at> wrote:
El miércoles, 14 de diciembre de 2011 14:53:41 UTC-5, ErwinP escribió:
Hello
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
Add a Panel and then place your widgets (TextCtrl, etc) on that, then it works for me. You would have less overhead processing if you used EVT_FOCUS_SET and EVT_KILL_FOCUS to check for when to set defaults, rather than on each keypress. It would also be more understandable and easy to maintain if you used the TextCtrl style TE_PROCESS_ENTER to check for return/enter presses, rather than checking manually (because using TE_PROCESS_ENTER checks all this in compiled C++ code, rather than Python).
···
On Sunday, October 26, 2014 7:16:47 PM UTC-7, sebastián lópez wrote:
Hi
I’m using wxpython ‘3.0.0.0’ and python 2.7.8 32bit and i want to use this behabiour but it fails
So when I press the tab control the selection doesn’t change.
On Sunday, October 26, 2014 7:16:47 PM UTC-7, sebastián lópez wrote:
Hi
I’m using wxpython ‘3.0.0.0’ and python 2.7.8 32bit and i want to use this behabiour but it fails
So when I press the tab control the selection doesn’t change.
Add a Panel and then place your widgets (TextCtrl, etc) on that, then it works for me. You would have less overhead processing if you used EVT_FOCUS_SET and EVT_KILL_FOCUS to check for when to set defaults, rather than on each keypress. It would also be more understandable and easy to maintain if you used the TextCtrl style TE_PROCESS_ENTER to check for return/enter presses, rather than checking manually (because using TE_PROCESS_ENTER checks all this in compiled C++ code, rather than Python).