X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b4354db179f5b9f3107cc532bb5232deccab90d0..96c9640205933ad0673d5af2c96af0816c50160c:/src/msw/button.cpp diff --git a/src/msw/button.cpp b/src/msw/button.cpp index e87917bd64..d00f877793 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 // ============================================================================ @@ -273,7 +277,7 @@ static wxTopLevelWindow *GetTLWParentIfNotBeingDeleted(wxWindow *win) // set this button as being currently default void wxButton::SetTmpDefault() { - wxTopLevelWindow * const tlw = GetTLWParentIfNotBeingDeleted(GetParent()); + wxTopLevelWindow * const tlw = GetTLWParentIfNotBeingDeleted(this); if ( !tlw ) return; @@ -287,7 +291,7 @@ void wxButton::SetTmpDefault() // unset this button as currently default, it may still stay permanent default void wxButton::UnsetTmpDefault() { - wxTopLevelWindow * const tlw = GetTLWParentIfNotBeingDeleted(GetParent()); + wxTopLevelWindow * const tlw = GetTLWParentIfNotBeingDeleted(this); if ( !tlw ) return; @@ -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;