]> git.saurik.com Git - wxWidgets.git/blobdiff - src/univ/menu.cpp
oops, restored the postpone-redraw-if-dirty test which was somehow left out
[wxWidgets.git] / src / univ / menu.cpp
index 0c9f850aa530e0594db68d23b9e63cce33e54e13..ba08a02a6ed8257f0a1b77dfc084f5f003cb82fc 100644 (file)
@@ -5,7 +5,7 @@
 // Modified by:
 // Created:     25.08.00
 // RCS-ID:      $Id$
-// Copyright:   (c) 2000 Vadim Zeitlin
+// Copyright:   (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
 // Licence:     wxWindows license
 /////////////////////////////////////////////////////////////////////////////
 
@@ -41,6 +41,8 @@
 
 #include "wx/popupwin.h"
 #include "wx/evtloop.h"
+#include "wx/dcclient.h"
+#include "wx/frame.h"
 
 #include "wx/univ/renderer.h"
 
@@ -599,10 +601,12 @@ void wxPopupMenuWindow::ClickItem(wxMenuItem *item)
     wxASSERT_MSG( !item->IsSeparator() && !item->IsSubMenu(),
                   _T("can't click this item") );
 
-    m_menu->ClickItem(item);
+    wxMenu* menu = m_menu;
 
     // close all menus
     DismissAndNotify();
+    
+    menu->ClickItem(item);
 }
 
 void wxPopupMenuWindow::OpenSubmenu(wxMenuItem *item, InputMethod how)
@@ -1961,7 +1965,7 @@ bool wxMenuBar::ProcessMouseEvent(const wxPoint& pt)
 
     // show the menu if we know that we should, even if we hadn't been showing
     // it before (this may happen if the previous menu was disabled)
-    if ( m_shouldShowMenu )
+    if ( m_shouldShowMenu && !m_menuShown)
     {
         // open the new menu if the old one we closed had been opened
         PopupCurrentMenu(FALSE /* don't select first item - as Windows does */);
@@ -2034,7 +2038,7 @@ void wxMenuBar::OnKeyDown(wxKeyEvent& event)
                 }
                 else // right
                 {
-                    if ( ++currentNew == (int)count )
+                    if ( ++currentNew == count )
                         currentNew = 0;
                 }
 
@@ -2221,6 +2225,11 @@ void wxMenuBar::PopupCurrentMenu(bool selectFirst)
             // that we pass 0 as width to position the menu exactly below the
             // item, not to the right of it
             wxRect rectItem = GetItemRect(m_current);
+
+           // Release mouse, because the menu will get the capture.
+           if (HasCapture())
+               ReleaseMouse();
+
             m_menuShown->Popup(ClientToScreen(rectItem.GetPosition()),
                                wxSize(0, rectItem.GetHeight()),
                                selectFirst);
@@ -2254,7 +2263,7 @@ void wxMenuBar::OnDismissMenu(bool dismissMenuBar)
 
 void wxMenuBar::OnDismiss()
 {
-    ReleaseCapture();
+    ReleaseMouse();
 
     if ( m_current != -1 )
     {