m_shouldShowMenu = false;
}
+wxMenuBar::wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long WXUNUSED(style))
+{
+ Init();
+
+ for (size_t i = 0; i < n; ++i )
+ Append(menus[i], titles[i]);
+}
+
void wxMenuBar::Attach(wxFrame *frame)
{
// maybe you really wanted to call Detach()?
// the menu when up/down one is
switch ( key )
{
- case WXK_MENU:
+ case WXK_ALT:
// Alt must be processed at wxWindow level too
event.Skip();
// fall through
void wxMenuBar::OnDismiss()
{
- if ( GetCapture() )
- {
+ if ( ReleaseMouseCapture() )
wxLogTrace(_T("mousecapture"), _T("Releasing mouse from wxMenuBar::OnDismiss"));
- GetCapture()->ReleaseMouse();
- }
-
+
if ( m_current != -1 )
{
size_t current = m_current;
GiveAwayFocus();
}
+bool wxMenuBar::ReleaseMouseCapture()
+{
+#if __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
+ // this point, preventing us from releasing the menu's capture. So to work
+ // around this, we release both captures, then put back the control's
+ // capture.
+ wxWindow *capture = GetCapture();
+ if ( capture )
+ {
+ capture->ReleaseMouse();
+
+ if ( capture == this )
+ return true;
+
+ bool had = HasCapture();
+
+ if ( had )
+ ReleaseMouse();
+
+ capture->CaptureMouse();
+
+ return had;
+ }
+#else
+ if ( HasCapture() )
+ {
+ ReleaseMouse();
+ return true;
+ }
+#endif
+ return false;
+}
+
void wxMenuBar::GiveAwayFocus()
{
GetFrame()->SetFocus();
// wxLogDebug( "Name of invoking window %s", menu->GetInvokingWindow()->GetName().c_str() );
- menu->Popup(ClientToScreen(wxPoint(x, y)), wxSize(0, 0));
+ menu->Popup(ClientToScreen(wxPoint(x, y)), wxSize(0,0));
// this is not very useful if the menu was popped up because of the mouse
// click but I think it is nice to do when it appears because of a key