From 73b4c33f05d9badc1b7401d3328328b265ac14df Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Thu, 7 Jul 2011 15:58:03 +0200 Subject: [PATCH] track if the mouse was released after menu open Make sure the menu isn't closed by the mouse up that is directly followed by the mouse down that opened the menu. --- AppKit/CPMenu/_CPMenuManager.j | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/AppKit/CPMenu/_CPMenuManager.j b/AppKit/CPMenu/_CPMenuManager.j index 9c7b27213..57f253a65 100644 --- a/AppKit/CPMenu/_CPMenuManager.j +++ b/AppKit/CPMenu/_CPMenuManager.j @@ -11,6 +11,7 @@ var STICKY_TIME_INTERVAL = 500, @implementation _CPMenuManager: CPObject { CPTimeInterval _startTime; + BOOL _hasMouseGoneUpAfterStartedTracking; int _scrollingState; CGPoint _lastGlobalLocation; @@ -87,6 +88,8 @@ var STICKY_TIME_INTERVAL = 500, return [self trackMenuBarButtonEvent:anEvent]; } + _hasMouseGoneUpAfterStartedTracking = NO; + [self trackEvent:anEvent]; } @@ -221,8 +224,13 @@ var STICKY_TIME_INTERVAL = 500, [CPEvent startPeriodicEventsAfterDelay:0.0 withPeriod:0.04]; } } - else if (type === CPLeftMouseUp && ([anEvent timestamp] - _startTime > (STICKY_TIME_INTERVAL + [activeMenu numberOfItems] * 5))) - [trackingMenu cancelTracking]; + else if (type === CPLeftMouseUp) + { + if (_hasMouseGoneUpAfterStartedTracking) + [trackingMenu cancelTracking]; + else + _hasMouseGoneUpAfterStartedTracking = YES; + } } // Prevent previous selected menu items from opening by stopping the timer if a