Marco Prosperi
2014-09-08 16:13:17 UTC
hello,
I have a textctrl with a wx.TE_PROCESS_ENTER style. I would like the
OnEnter function to be called not only when the user press enter but also
when the textctrl looses focus (e.g.: the user has clicked in another
textctrl). How can I achieve this?
I've tried this but it doesn't work (and it seems to freeze the GUI
somehow):
def OnKillFocus(self, evt):
self.log.WriteText('OnKillFocus\n')
kType = wx.EVT_KEY_DOWN.typeId
ke=wx.KeyEvent(kType)
ke.SetUnicodeKey(wx.WXK_RETURN)
ke.SetEventObject( self.tc1 )
ke.SetId( self.tc1.GetId() )
self.tc1.EmulateKeyPress(ke)
evt.Skip()
To play around I've tried using this method with textctrl demo (enabling
t1.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus), adding wx.TE_PROCESS_ENTER to
t1 and replacing wx.WXK_RETURN with wx.WXK_SPACE to see something but
nothing happens and I cannot select the text in self.tc1 anymore after t1
has lost focus
any suggestion?
thanks, Marco
I have a textctrl with a wx.TE_PROCESS_ENTER style. I would like the
OnEnter function to be called not only when the user press enter but also
when the textctrl looses focus (e.g.: the user has clicked in another
textctrl). How can I achieve this?
I've tried this but it doesn't work (and it seems to freeze the GUI
somehow):
def OnKillFocus(self, evt):
self.log.WriteText('OnKillFocus\n')
kType = wx.EVT_KEY_DOWN.typeId
ke=wx.KeyEvent(kType)
ke.SetUnicodeKey(wx.WXK_RETURN)
ke.SetEventObject( self.tc1 )
ke.SetId( self.tc1.GetId() )
self.tc1.EmulateKeyPress(ke)
evt.Skip()
To play around I've tried using this method with textctrl demo (enabling
t1.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus), adding wx.TE_PROCESS_ENTER to
t1 and replacing wx.WXK_RETURN with wx.WXK_SPACE to see something but
nothing happens and I cannot select the text in self.tc1 anymore after t1
has lost focus
any suggestion?
thanks, Marco
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.