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.
This commit is contained in:
Klaas Pieter Annema
2011-07-07 16:04:10 +02:00
parent ad30f4dcbb
commit 73b4c33f05
+10 -2
View File
@@ -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