From 8e86978af59b6465801bf1bd32f66a5d68280421 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 10 Nov 2007 01:15:03 +0000 Subject: [PATCH] don't forward Enter presses to the default button if any of the ancestor windows has DLGC_WANTMESSAGE dialog code (slightly modified patch 1828309) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49805 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/window.cpp | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 8cea552169..87122d67bd 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -2219,13 +2219,6 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg) case VK_RETURN: { - if ( (lDlgCode & DLGC_WANTMESSAGE) && !bCtrlDown ) - { - // control wants to process Enter itself, don't - // call IsDialogMessage() which would consume it - return false; - } - #if wxUSE_BUTTON // currently active button should get enter press even // if there is a default button elsewhere so check if @@ -2247,9 +2240,32 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg) } else // not a button itself, do we have default button? { - wxTopLevelWindow * - tlw = wxDynamicCast(wxGetTopLevelParent(this), - wxTopLevelWindow); + // check if this window or any of its ancestors + // wants the message for itself (we always reserve + // Ctrl-Enter for dialog navigation though) + wxWindow *win = this; + if ( !bCtrlDown ) + { + while ( win && !win->IsTopLevel() ) + { + if ( lDlgCode & DLGC_WANTMESSAGE ) + { + // as it wants to process Enter itself, + // don't call IsDialogMessage() which + // would consume it + return false; + } + + win = win->GetParent(); + } + } + else // bCtrlDown + { + win = wxGetTopLevelParent(win); + } + + wxTopLevelWindow * const + tlw = wxDynamicCast(win, wxTopLevelWindow); if ( tlw ) { btn = wxDynamicCast(tlw->GetDefaultItem(), -- 2.45.2