+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;
+}
+