Fix for menu selection that was broken with the change to CPEvent timestamp

This commit is contained in:
Blair Duncan
2012-04-23 16:51:10 -04:00
parent 7efc8230a2
commit 5b6779a3a9
3 changed files with 13 additions and 37 deletions
+5 -5
View File
@@ -126,8 +126,8 @@ var STICKY_TIME_INTERVAL = 0.5,
}
if (_keyBuffer)
{
if (([anEvent timestamp] - _startTime) > (STICKY_TIME_INTERVAL + [activeMenu numberOfItems] / 2))
{ // periodic events have a timestamp of 0 so use the currentTimestamp
if (([CPEvent currentTimestamp] - _startTime) > (STICKY_TIME_INTERVAL + [activeMenu numberOfItems] / 2))
[self selectNextItemBeginningWith:_keyBuffer inMenu:menu clearBuffer:YES];
if (type === CPPeriodic)
@@ -245,7 +245,7 @@ var STICKY_TIME_INTERVAL = 0.5,
3. The user clicks, drags and then releases. Tracking ends.
*/
if (_mouseWasDragged || ([anEvent timestamp] - _startTime > STICKY_TIME_INTERVAL))
if (_mouseWasDragged || ([CPEvent currentTimestamp] - _startTime > STICKY_TIME_INTERVAL))
{
/*
Close the menu if:
@@ -485,7 +485,7 @@ var STICKY_TIME_INTERVAL = 0.5,
{
if (!_keyBuffer)
{
_startTime = [CPDate date];
_startTime = [CPEvent currentTimestamp];
_keyBuffer = character;
[CPEvent stopPeriodicEvents];
@@ -522,7 +522,7 @@ var STICKY_TIME_INTERVAL = 0.5,
_keyBuffer = Nil;
}
else
_startTime = [CPDate date];
_startTime = [CPEvent currentTimestamp];
}
- (void)scrollToBeginningOfDocument:(CPMenu)menu
+8 -14
View File
@@ -1,14 +1,13 @@
/*
* AppController.j
* CPMenuTest
* CPMenu
*
* Created by Alexander Ljungberg on August 31, 2010.
* Copyright 2010, WireLoad, LLC All rights reserved.
* Created by Blair Duncan on April 23, 2012.
* Copyright 2012, SGL Studio, BBDO Toronto All rights reserved.
*/
@import <Foundation/CPObject.j>
@import "MyView.j"
@implementation AppController : CPObject
{
@@ -17,16 +16,10 @@
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
contentView = [[MyView alloc] initWithFrame:CGRectMakeZero()];
contentView = [theWindow contentView],
popupButton = [[CPPopUpButton alloc] initWithFrame:CGRectMakeZero()];
[contentView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[theWindow setContentView:contentView];
var popupButton = [[CPPopUpButton alloc] initWithFrame:CGRectMakeZero()];
[popupButton addItemWithTitle:@"Item 1"];
[popupButton addItemWithTitle:@"Item 2"];
[popupButton addItemWithTitle:@"Item 3"];
[popupButton addItemsWithTitles:[[CPFontManager sharedFontManager] availableFonts]];
[popupButton sizeToFit];
[popupButton setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
@@ -37,7 +30,8 @@
[theWindow orderFront:self];
// Uncomment the following line to turn on the standard menu bar.
[CPMenu setMenuBarVisible:YES];
//[CPMenu setMenuBarVisible:YES];
}
@end
-18
View File
@@ -1,18 +0,0 @@
@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