]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
resolving conflicts in files I had forgot to commit (sorry)
[wxWidgets.git] / src / msw / window.cpp
index 91116b67ac5a916a4c33c6aa49ff45f1125b9252..5762e1de98547a37ba8c13aaed6f4d9e37635ae0 100644 (file)
@@ -1837,6 +1837,25 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
                         bProcess = FALSE;
                     break;
 
+                case VK_ESCAPE:
+                    {
+#if wxUSE_BUTTON
+                        wxButton *btn = wxDynamicCast(FindWindow(wxID_CANCEL),
+                                                      wxButton);
+                        if ( btn && btn->IsEnabled() )
+                        {
+                            // if we do have a cancel button, do press it
+                            btn->MSWCommand(BN_CLICKED, 0 /* unused */);
+
+                            // we consumed the message
+                            return TRUE;
+                        }
+#endif // wxUSE_BUTTON
+
+                        bProcess = FALSE;
+                    }
+                    break;
+
                 case VK_RETURN:
                     {
                         if ( (lDlgCode & DLGC_WANTMESSAGE) && !bCtrlDown )
@@ -1950,8 +1969,7 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
         }
 #endif // 1/0
 
-        // we handle VK_ESCAPE ourselves in wxDialog::OnCharHook() and we
-        // shouldn't let IsDialogMessage() get it as it _always_ eats the
+        // don't let IsDialogMessage() get VK_ESCAPE as it _always_ eats the
         // message even when there is no cancel button and when the message is
         // needed by the control itself: in particular, it prevents the tree in
         // place edit control from being closed with Escape in a dialog
@@ -2866,8 +2884,20 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
                 wxPoint pt(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
 
                 wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU, GetId(), pt);
-                evtCtx.SetEventObject(this);
-                processed = GetEventHandler()->ProcessEvent(evtCtx);
+
+                // we could have got an event from our child, reflect it back
+                // to it if this is the case
+                wxWindow *win = NULL;
+                if ( wParam != m_hWnd )
+                {
+                    win = FindItemByHWND((WXHWND)wParam);
+                }
+
+                if ( !win )
+                    win = this;
+
+                evtCtx.SetEventObject(win);
+                processed = win->GetEventHandler()->ProcessEvent(evtCtx);
             }
             break;
 #endif