X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/906c935a80b10d53cecf57f71ab5f3f4f1d529ec..8a31648287be0ef976f133de2786b137f1e98340:/src/msw/button.cpp?ds=inline diff --git a/src/msw/button.cpp b/src/msw/button.cpp index e87917bd64..3e9bfb5739 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -62,6 +62,10 @@ // macros // ---------------------------------------------------------------------------- +BEGIN_EVENT_TABLE(wxButton, wxButtonBase) + EVT_CHAR_HOOK(wxButton::OnCharHook) +END_EVENT_TABLE() + // ============================================================================ // implementation // ============================================================================ @@ -370,6 +374,25 @@ void wxButton::Command(wxCommandEvent & event) // event/message handlers // ---------------------------------------------------------------------------- +void wxButton::OnCharHook(wxKeyEvent& event) +{ + // We want to ensure that the button always processes Enter key events + // itself, even if it's inside some control that normally takes over them + // (this happens when the button is part of an in-place editor control for + // example). + if ( event.GetKeyCode() == WXK_RETURN ) + { + // We should ensure that subsequent key events are still generated even + // if we did handle EVT_CHAR_HOOK (normally this would suppress their + // generation). + event.DoAllowNextEvent(); + } + else + { + event.Skip(); + } +} + bool wxButton::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) { bool processed = false;