fix context menu only closes after two clicks

This is a regression from 73b4c33f05.
Because we were only tracking wether the left mouse button went up after a contextual menu (which is opened with the right mouse)
would only close after the second left mouse up.
This commit is contained in:
Klaas Pieter Annema
2011-07-14 11:15:34 +02:00
parent d1dd725848
commit d115d2ef47
3 changed files with 32 additions and 10 deletions
+2 -2
View File
@@ -102,7 +102,7 @@ var STICKY_TIME_INTERVAL = 500,
if (type === CPAppKitDefined)
return [self completeTracking];
[CPApp setTarget:self selector:@selector(trackEvent:) forNextEventMatchingMask:CPKeyDownMask | CPPeriodicMask | CPMouseMovedMask | CPLeftMouseDraggedMask | CPLeftMouseUpMask | CPAppKitDefinedMask | CPScrollWheelMask untilDate:nil inMode:nil dequeue:YES];
[CPApp setTarget:self selector:@selector(trackEvent:) forNextEventMatchingMask:CPKeyDownMask | CPPeriodicMask | CPMouseMovedMask | CPLeftMouseDraggedMask | CPLeftMouseUpMask | CPRightMouseUpMask | CPAppKitDefinedMask | CPScrollWheelMask untilDate:nil inMode:nil dequeue:YES];
if (type === CPKeyDown)
{
@@ -224,7 +224,7 @@ var STICKY_TIME_INTERVAL = 500,
[CPEvent startPeriodicEventsAfterDelay:0.0 withPeriod:0.04];
}
}
else if (type === CPLeftMouseUp)
else if (type === CPLeftMouseUp || type === CPRightMouseUp)
{
if (_hasMouseGoneUpAfterStartedTracking)
[trackingMenu cancelTracking];
+12 -8
View File
@@ -8,6 +8,7 @@
@import <Foundation/CPObject.j>
@import "MyView.j"
@implementation AppController : CPObject
{
@@ -16,19 +17,22 @@
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView];
contentView = [[MyView alloc] initWithFrame:CGRectMakeZero()];
var label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[contentView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[theWindow setContentView:contentView];
[label setStringValue:@"Hello World!"];
[label setFont:[CPFont boldSystemFontOfSize:24.0]];
var popupButton = [[CPPopUpButton alloc] initWithFrame:CGRectMakeZero()];
[label sizeToFit];
[popupButton addItemWithTitle:@"Item 1"];
[popupButton addItemWithTitle:@"Item 2"];
[popupButton addItemWithTitle:@"Item 3"];
[popupButton sizeToFit];
[label setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
[label setCenter:[contentView center]];
[popupButton setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
[popupButton setCenter:[contentView center]];
[contentView addSubview:label];
[contentView addSubview:popupButton];
[theWindow orderFront:self];
+18
View File
@@ -0,0 +1,18 @@
@import <AppKit/CPView.j>
@implementation MyView : CPView
{
}
- (CPMenu)menu
{
var menu = [[CPMenu alloc] initWithTitle:@""];
[menu addItemWithTitle:@"Item 1" action:nil keyEquivalent:nil];
[menu addItemWithTitle:@"Item 2" action:nil keyEquivalent:nil];
[menu addItemWithTitle:@"Item 3" action:nil keyEquivalent:nil];
return menu;
}
@end