From f5667d3c9dd05974a6ab0201b119fa92edb9e96c Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Mon, 12 Apr 2010 15:04:50 +0000 Subject: [Author: thomasvl] NSEvent throws if you call -characters on a non key event, so instead of checking the requested mask, we have to check the event type (say someone uses any event as the mask, and it's a click event...) Also handle keydown or up for the tab check. R=dmaclach,stuartmorgan DELTA=8 (1 added, 0 deleted, 7 changed) --- AppKit/GTMNSAnimation+Duration.m | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'AppKit/GTMNSAnimation+Duration.m') diff --git a/AppKit/GTMNSAnimation+Duration.m b/AppKit/GTMNSAnimation+Duration.m index 5155c38..18ebf80 100644 --- a/AppKit/GTMNSAnimation+Duration.m +++ b/AppKit/GTMNSAnimation+Duration.m @@ -23,21 +23,22 @@ const NSUInteger kGTMLeftMouseDownAndKeyDownMask NSTimeInterval GTMModifyDurationBasedOnCurrentState(NSTimeInterval duration, NSUInteger eventMask) { - NSEvent *event = [NSApp currentEvent]; - if (eventMask & NSEventMaskFromType([event type])) { - NSUInteger modifiers = [event modifierFlags]; + NSEvent *currentEvent = [NSApp currentEvent]; + NSUInteger currentEventMask = NSEventMaskFromType([currentEvent type]); + if (eventMask & currentEventMask) { + NSUInteger modifiers = [currentEvent modifierFlags]; if (!(modifiers & (NSAlternateKeyMask | NSCommandKeyMask))) { if (modifiers & NSShiftKeyMask) { // 25 is the ascii code generated for a shift-tab (End-of-message) - // The shift modifier is ignored if it is applied to a Tab key down. + // The shift modifier is ignored if it is applied to a Tab key down/up. // Tab and shift-tab are often used for navigating around UI elements, // and in the majority of cases slowing down the animations while // navigating around UI elements is not desired. - if ((eventMask & NSKeyDownMask) + if ((currentEventMask & (NSKeyDownMask | NSKeyUpMask)) && !(modifiers & NSControlKeyMask) - && ([[event characters] length] == 1) - && ([[event characters] characterAtIndex:0] == 25)) { + && ([[currentEvent characters] length] == 1) + && ([[currentEvent characters] characterAtIndex:0] == 25)) { duration = duration; } else { duration *= 5.0; -- cgit v1.2.3