wxDialog gobbles Enter key

I am attempting to catch all keystrokes on a wxPanel in a wxDialog. Everything seems to come through except the Enter key. (This works fine when attached to a wxFrame instead). I'm guessing the dialog is trying to trap Enter for activating the default button.

Is there some way to change this behavior and let me grab the Enter key?

I could use wxTE_PROCESS_ENTER style on a Text control, but that won't help on other things (e.g. wxChoice). I tried catching wxEVT_NAVIGATION_KEY but that only seems to work for the Tab key.

Any ideas?

Thanks,
Michael
Py2.7.2, Win7, wxPy 2.9.3.1

Try using EVT_CHAR_HOOK bound to the dialog. I think that is where ESC and Enter are caught in dialogs for platforms that don't have native processing of those in a dialog.

···

On 1/14/12 9:24 AM, Michael Hipp wrote:

I am attempting to catch all keystrokes on a wxPanel in a wxDialog.
Everything seems to come through except the Enter key. (This works fine
when attached to a wxFrame instead). I'm guessing the dialog is trying
to trap Enter for activating the default button.

Is there some way to change this behavior and let me grab the Enter key?

I could use wxTE_PROCESS_ENTER style on a Text control, but that won't
help on other things (e.g. wxChoice). I tried catching
wxEVT_NAVIGATION_KEY but that only seems to work for the Tab key.

Any ideas?

--
Robin Dunn
Software Craftsman

Thank you. Looks like this will work perfectly.

Once that event is in-hand, what is the difference between these:
   event.GetKeyCode()
   event.KeyCode()
   event.m_keyCode?

Thanks,
Michael

···

On 2012-01-14 1:30 PM, Robin Dunn wrote:

On 1/14/12 9:24 AM, Michael Hipp wrote:

I am attempting to catch all keystrokes on a wxPanel in a wxDialog.
Everything seems to come through except the Enter key. (This works fine
when attached to a wxFrame instead). I'm guessing the dialog is trying
to trap Enter for activating the default button.

Try using EVT_CHAR_HOOK bound to the dialog. I think that is where ESC and
Enter are caught in dialogs for platforms that don't have native processing of
those in a dialog.

In much older versions of wxPython the method was KeyCode() which returned the value of the m_keyCode attribute. That was deprecated and replaced with GetKeyCode(). For a while I had "KeyCode = GetKeyCode" for a compatibility alias, but then I removed it and now KeyCode is a Python property with GetKeyCode as its getter function.

···

On 1/14/12 1:18 PM, Michael Hipp wrote:

On 2012-01-14 1:30 PM, Robin Dunn wrote:

On 1/14/12 9:24 AM, Michael Hipp wrote:

I am attempting to catch all keystrokes on a wxPanel in a wxDialog.
Everything seems to come through except the Enter key. (This works fine
when attached to a wxFrame instead). I'm guessing the dialog is trying
to trap Enter for activating the default button.

Try using EVT_CHAR_HOOK bound to the dialog. I think that is where ESC
and
Enter are caught in dialogs for platforms that don't have native
processing of
those in a dialog.

Thank you. Looks like this will work perfectly.

Once that event is in-hand, what is the difference between these:
event.GetKeyCode()
event.KeyCode()
event.m_keyCode?

--
Robin Dunn
Software Craftsman