EVT_TEXT_ENTER can not be caught in a subclass of wx.Dialog

S

Sean

Hi,
I found if a wx.TextCtrl is used in a subclass of wx.Dialog, the
event wx.EVT_TEXT_ENTER can not be caught, that is, key code of RETURN
can not be indentified.

class MyDialog(wx.Dialog):
def __init__(self,parent,pos,size,style):
...
self.t1 = wx.TextCtrl(self, -1, "", size=(125, -1))
self.t1.Bind(wx.EVT_CHAR, self.OnChar,self.t1)
...

def OnChar(self, event):
if (event.GetKeyCode() == 13):
print "%d"%event.GetKeyCode()
else:
print "%d"%event.GetKeyCode()
event.Skip()


How could I effectively bind a handler to EVT_TEXT_ENTER in it?


Thanks,
Sean
 
C

Cliff Wells

Hi,
I found if a wx.TextCtrl is used in a subclass of wx.Dialog, the
event wx.EVT_TEXT_ENTER can not be caught, that is, key code of RETURN
can not be indentified.

class MyDialog(wx.Dialog):
def __init__(self,parent,pos,size,style):
...
self.t1 = wx.TextCtrl(self, -1, "", size=(125, -1))
self.t1.Bind(wx.EVT_CHAR, self.OnChar,self.t1)
...

def OnChar(self, event):
if (event.GetKeyCode() == 13):
print "%d"%event.GetKeyCode()
else:
print "%d"%event.GetKeyCode()
event.Skip()


How could I effectively bind a handler to EVT_TEXT_ENTER in it?

You need to specify the following style for the textctrl:

self.t1 = wx.TextCtrl(self, -1, "", style = wx.TE_PROCESS_ENTER)

Regards,
Cliff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top