/////////////////////////////////////////////////////////////////////////////
-// Name: univ/menu.cpp
+// Name: src/univ/menu.cpp
// Purpose: wxMenuItem, wxMenu and wxMenuBar implementation
// Author: Vadim Zeitlin
// Modified by:
// headers
// ----------------------------------------------------------------------------
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
- #pragma implementation "univmenuitem.h"
- #pragma implementation "univmenu.h"
-#endif
-
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
+#if wxUSE_MENUS
+
#ifndef WX_PRECOMP
#include "wx/dynarray.h"
#include "wx/control.h" // for FindAccelIndex()
#include "wx/log.h"
#endif // WX_PRECOMP
-#if wxUSE_MENUS
-
#include "wx/popupwin.h"
#include "wx/evtloop.h"
#include "wx/dcclient.h"
// called when a submenu is dismissed
void OnSubmenuDismiss(bool dismissParent);
+ // the default wxMSW wxPopupTransientWindow::OnIdle disables the capture
+ // when the cursor is inside the popup, which dsables the menu tracking
+ // so override it to do nothing
+#ifdef __WXMSW__
+ void OnIdle(wxIdleEvent& WXUNUSED(event)) { }
+#endif
+
// get the currently selected item (may be NULL)
wxMenuItem *GetCurrentItem() const
{
EVT_LEFT_UP(wxPopupMenuWindow::OnLeftUp)
EVT_MOTION(wxPopupMenuWindow::OnMouseMove)
EVT_LEAVE_WINDOW(wxPopupMenuWindow::OnMouseLeave)
+#ifdef __WXMSW__
+ EVT_IDLE(wxPopupMenuWindow::OnIdle)
+#endif
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(wxMenuBar, wxMenuBarBase)
wxPopupTransientWindow::Popup(focus);
+ // the base class no-longer captures the mouse automatically when Popup
+ // is called, so do it here to allow the menu tracking to work
+ if ( !HasCapture() )
+ CaptureMouse();
+
#ifdef __WXMSW__
// ensure that this window is really on top of everything: without using
// SetWindowPos() it can be covered by its parent menu which is not
}
wxPopupTransientWindow::Dismiss();
+
+ ResetCurrent();
}
void wxPopupMenuWindow::OnDismiss()
HandleDismiss(true);
}
-void wxPopupMenuWindow::OnSubmenuDismiss(bool dismissParent)
+void wxPopupMenuWindow::OnSubmenuDismiss(bool WXUNUSED(dismissParent))
{
m_hasOpenSubMenu = false;
-
- // we are closing whole menu so remove current highlight
- if ( dismissParent )
- ResetCurrent();
}
void wxPopupMenuWindow::HandleDismiss(bool dismissParent)
{
- ResetCurrent();
-
m_menu->OnDismiss(dismissParent);
}
void wxPopupMenuWindow::OnKeyDown(wxKeyEvent& event)
{
- if ( !ProcessKeyDown(event.GetKeyCode()) )
+ wxMenuBar *menubar = m_menu->GetMenuBar();
+
+ if ( menubar )
+ {
+ menubar->ProcessEvent(event);
+ }
+ else if ( !ProcessKeyDown(event.GetKeyCode()) )
{
event.Skip();
}
{
if ( ReleaseMouseCapture() )
wxLogTrace(_T("mousecapture"), _T("Releasing mouse from wxMenuBar::OnDismiss"));
-
+
if ( m_current != -1 )
{
size_t current = m_current;
bool wxMenuBar::ReleaseMouseCapture()
{
-#if __WXX11__
+#ifdef __WXX11__
// With wxX11, when a menu is closed by clicking away from it, a control
// under the click will still get an event, even though the menu has the
// capture (bug?). So that control may already have taken the capture by
if ( had )
ReleaseMouse();
-
+
capture->CaptureMouse();
return had;
}
#endif // wxUSE_MENUS
-