]> git.saurik.com Git - wxWidgets.git/commitdiff
don't forward Enter presses to the default button if any of the ancestor windows...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 10 Nov 2007 01:15:03 +0000 (01:15 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 10 Nov 2007 01:15:03 +0000 (01:15 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49805 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/window.cpp

index 8cea552169a4ee9533f10fbed3d65e5b5dc0ca9e..87122d67bdf3295da8ac4daa4d876b90a63d4663 100644 (file)
@@ -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(),