aboutsummaryrefslogtreecommitdiff
path: root/AppKit
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2010-03-26 00:33:37 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2010-03-26 00:33:37 +0000
commit2f5cf3e2da5594aa8ba610261130a22fccf0117f (patch)
tree285a172c720e655e95ff217bba9359dcbee9569b /AppKit
parent8d1d2d027444e361154bc6a724e5d1b384ea21ea (diff)
[Author: dmaclach]
Stop animation slow down applying to shift-tabs. 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. TBR=thomasvl,mrossetti DELTA=24 (15 added, 4 deleted, 5 changed)
Diffstat (limited to 'AppKit')
-rw-r--r--AppKit/GTMNSAnimation+Duration.h16
-rw-r--r--AppKit/GTMNSAnimation+Duration.m13
2 files changed, 20 insertions, 9 deletions
diff --git a/AppKit/GTMNSAnimation+Duration.h b/AppKit/GTMNSAnimation+Duration.h
index 5d45378..060d0b8 100644
--- a/AppKit/GTMNSAnimation+Duration.h
+++ b/AppKit/GTMNSAnimation+Duration.h
@@ -25,6 +25,10 @@
// control keys modifies the normal duration for an animation making it slower.
// Currently only modifies the duration if the current event is masked by
// eventMask and only the control and/or shift modifiers are down.
+// The shift modifier is ignored if it is applied to a Tab key down.
+// 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.
NSTimeInterval GTMModifyDurationBasedOnCurrentState(NSTimeInterval duration,
NSUInteger eventMask);
@@ -42,16 +46,14 @@ extern const NSUInteger kGTMLeftMouseDownAndKeyDownMask;
// based on the current event when the animation is created. If the animation
// is to be reused, the duration for the event should be reset with
// gtm_setDuration each time the animation is started.
-// Currently only modifies the duration if the current event is masked by
-// eventMask and only the control and/or shift modifiers are down.
+// See notes for GTMModifyDurationBasedOnCurrentState for more info.
- (id)gtm_initWithDuration:(NSTimeInterval)duration
eventMask:(NSUInteger)eventMask
animationCurve:(NSAnimationCurve)animationCurve;
// Sets the duration by taking the duration passed in and calling
// GTMModifyDurationBasedOnCurrentState to calculate the real duration.
-// Currently only modifies the duration if the current event is masked by
-// eventMask and only the control and/or shift modifiers are down.
+// See notes for GTMModifyDurationBasedOnCurrentState for more info.
- (void)gtm_setDuration:(NSTimeInterval)duration
eventMask:(NSUInteger)eventMask;
@end
@@ -64,8 +66,7 @@ extern const NSUInteger kGTMLeftMouseDownAndKeyDownMask;
// Sets the duration by taking the duration passed in and calling
// GTMModifyDurationBasedOnCurrentState to calculate the real duration.
-// Currently only modifies the duration if the current event is masked by
-// eventMask and only the control and/or shift modifiers are down.
+// See notes for GTMModifyDurationBasedOnCurrentState for more info.
- (void)gtm_setDuration:(NSTimeInterval)duration
eventMask:(NSUInteger)eventMask;
@end
@@ -74,8 +75,7 @@ extern const NSUInteger kGTMLeftMouseDownAndKeyDownMask;
// Sets the duration by taking the duration passed in and calling
// GTMModifyDurationBasedOnCurrentState to calculate the real duration.
-// Currently only modifies the duration if the current event is masked by
-// eventMask and only the control and/or shift modifiers are down.
+// See notes for GTMModifyDurationBasedOnCurrentState for more info.
- (void)gtm_setDuration:(CFTimeInterval)duration
eventMask:(NSUInteger)events;
@end
diff --git a/AppKit/GTMNSAnimation+Duration.m b/AppKit/GTMNSAnimation+Duration.m
index c47772b..02f2b67 100644
--- a/AppKit/GTMNSAnimation+Duration.m
+++ b/AppKit/GTMNSAnimation+Duration.m
@@ -29,7 +29,18 @@ NSTimeInterval GTMModifyDurationBasedOnCurrentState(NSTimeInterval duration,
if (!(modifiers & (NSAlternateKeyMask |
NSCommandKeyMask))) {
if (modifiers & NSShiftKeyMask) {
- duration *= 5.0;
+ // 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.
+ // 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)
+ && ([[event characters] length])
+ && ([[event characters] characterAtIndex:0] == 25)) {
+ duration = duration;
+ } else {
+ duration *= 5.0;
+ }
}
// These are additive, so shift+control returns 10 * duration.
if (modifiers & NSControlKeyMask) {