aboutsummaryrefslogtreecommitdiff
path: root/AppKit
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2010-04-12 15:04:50 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2010-04-12 15:04:50 +0000
commitf5667d3c9dd05974a6ab0201b119fa92edb9e96c (patch)
tree3bbcf1f5889c23a226b1c85acb5ea22663ecfe61 /AppKit
parent8fa3e4efa6dda752d2a9f7aefeafb7447ec9aaef (diff)
[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)
Diffstat (limited to 'AppKit')
-rw-r--r--AppKit/GTMNSAnimation+Duration.m15
1 files changed, 8 insertions, 7 deletions
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;