wx.TE_PROCESS_ENTER but still no event

Hi,

I have textctrl controls I like to press the enter key, I am setting the above style but still don't see the event (checked with WIT).

The control in question has a style=1536, but when I enter a number and press enter I only see:

EVT_TEXT
EVT_KEY_UP
EVT_CHAR_HOOK
EVT_KEY_DOWN
EVT_CHAR
EVT_KILL_FOCUS

The control is in a panel which in turn is on a dialog.

What am I missing?

Werner

Forgot to mention the version:
2.9.4.0.b20120623

···

On 08/11/2012 10:37, Werner wrote:

Hi,

I have textctrl controls I like to press the enter key, I am setting the above style but still don't see the event (checked with WIT).

The control in question has a style=1536, but when I enter a number and press enter I only see:

EVT_TEXT
EVT_KEY_UP
EVT_CHAR_HOOK
EVT_KEY_DOWN
EVT_CHAR
EVT_KILL_FOCUS

The control is in a panel which in turn is on a dialog.

What am I missing?

Werner

Hi Werner,

I had the same problem in the past.
So, to resolve it, I create the panel with option "style=0".
Before :
wx.Panel(self, -1, style=wx.TAB_TRAVERSAL)
Now :
wx.Panel(self, -1, style=0)

And in EvtChar :
             if evt.GetKeyCode() in [wx.WXK_RETURN, wx.WXK_NUMPAD_ENTER] :
                 obj = evt.GetEventObject()
                 try :
                     tmp = obj.IsSingleLine()
                 except :
                     tmp = True
                 if tmp :
                     obj.Navigate()
                     return

Hugues JEAN-BAPTISTE (hjb@agorinfo.fr)
AGORINFO S.A.S. (http://www.agorinfo.fr)

Le 08/11/2012 10:47, Werner a �crit :

···

On 08/11/2012 10:37, Werner wrote:

Hi,

I have textctrl controls I like to press the enter key, I am setting the above style but still don't see the event (checked with WIT).

The control in question has a style=1536, but when I enter a number and press enter I only see:

EVT_TEXT
EVT_KEY_UP
EVT_CHAR_HOOK
EVT_KEY_DOWN
EVT_CHAR
EVT_KILL_FOCUS

The control is in a panel which in turn is on a dialog.

What am I missing?

Werner

Forgot to mention the version:
2.9.4.0.b20120623

Hi Hugues,

···

On 08/11/2012 12:23, Hugues JEAN-BAPTISTE wrote:

Hi Werner,

I had the same problem in the past.
So, to resolve it, I create the panel with option "style=0".
Before :
wx.Panel(self, -1, style=wx.TAB_TRAVERSAL)
Now :
wx.Panel(self, -1, style=0)

And in EvtChar :
            if evt.GetKeyCode() in [wx.WXK_RETURN, wx.WXK_NUMPAD_ENTER] :
                obj = evt.GetEventObject()
                try :
                    tmp = obj.IsSingleLine()
                except :
                    tmp = True
                if tmp :
                    obj.Navigate()
                    return

The EVT_CHAR trick works.

Robin, may I suggest that the documentation of wx.TE_PROCESS_ENTER mentions that it will not work on a dialog as the dialog catches the enter event and fires the default button handler.

Werner