mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
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:
@@ -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];
|
||||
|
||||
@@ -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];
|
||||
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user