| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/ui/cocoa/clickhold_button_cell.h" | 5 #import "chrome/browser/ui/cocoa/clickhold_button_cell.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 // Minimum and maximum click-hold timeout. | 9 // Minimum and maximum click-hold timeout. |
| 10 static const NSTimeInterval kMinTimeout = 0.0; | 10 static const NSTimeInterval kMinTimeout = 0.0; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 @implementation ClickHoldButtonCell | 23 @implementation ClickHoldButtonCell |
| 24 | 24 |
| 25 @synthesize enableClickHold = enableClickHold_; | 25 @synthesize enableClickHold = enableClickHold_; |
| 26 @synthesize enableRightClick = enableRightClick_; | 26 @synthesize enableRightClick = enableRightClick_; |
| 27 @synthesize clickHoldTimeout = clickHoldTimeout_; | 27 @synthesize clickHoldTimeout = clickHoldTimeout_; |
| 28 @synthesize trackOnlyInRect = trackOnlyInRect_; | 28 @synthesize trackOnlyInRect = trackOnlyInRect_; |
| 29 @synthesize activateOnDrag = activateOnDrag_; | 29 @synthesize activateOnDrag = activateOnDrag_; |
| 30 @synthesize clickHoldTarget = clickHoldTarget_; | 30 @synthesize clickHoldTarget = clickHoldTarget_; |
| 31 @synthesize clickHoldAction = clickHoldAction_; | 31 @synthesize clickHoldAction = clickHoldAction_; |
| 32 @synthesize accessibilityShowMenuTarget = accessibilityShowMenuTarget_; |
| 33 @synthesize accessibilityShowMenuAction = accessibilityShowMenuAction_; |
| 32 | 34 |
| 33 // Overrides: | 35 // Overrides: |
| 34 | 36 |
| 35 + (BOOL)prefersTrackingUntilMouseUp { | 37 + (BOOL)prefersTrackingUntilMouseUp { |
| 36 return NO; | 38 return NO; |
| 37 } | 39 } |
| 38 | 40 |
| 39 - (id)init { | 41 - (id)init { |
| 40 if ((self = [super init])) | 42 if ((self = [super init])) |
| 41 [self resetToDefaults]; | 43 [self resetToDefaults]; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 58 if ((self = [super initTextCell:string])) | 60 if ((self = [super initTextCell:string])) |
| 59 [self resetToDefaults]; | 61 [self resetToDefaults]; |
| 60 return self; | 62 return self; |
| 61 } | 63 } |
| 62 | 64 |
| 63 - (void)accessibilityPerformAction:(NSString*)action { | 65 - (void)accessibilityPerformAction:(NSString*)action { |
| 64 if ([action isEqualToString:NSAccessibilityShowMenuAction] && | 66 if ([action isEqualToString:NSAccessibilityShowMenuAction] && |
| 65 [self shouldExposeAccessibilityShowMenu]) { | 67 [self shouldExposeAccessibilityShowMenu]) { |
| 66 NSControl* controlView = static_cast<NSControl*>([self controlView]); | 68 NSControl* controlView = static_cast<NSControl*>([self controlView]); |
| 67 if (controlView) | 69 if (controlView) |
| 68 [controlView sendAction:clickHoldAction_ to:clickHoldTarget_]; | 70 [controlView sendAction:accessibilityShowMenuAction_ |
| 71 to:accessibilityShowMenuTarget_]; |
| 69 return; | 72 return; |
| 70 } | 73 } |
| 71 | 74 |
| 72 [super accessibilityPerformAction:action]; | 75 [super accessibilityPerformAction:action]; |
| 73 } | 76 } |
| 74 | 77 |
| 75 - (BOOL)startTrackingAt:(NSPoint)startPoint | 78 - (BOOL)startTrackingAt:(NSPoint)startPoint |
| 76 inView:(NSView*)controlView { | 79 inView:(NSView*)controlView { |
| 77 return enableClickHold_ ? YES : | 80 return enableClickHold_ ? YES : |
| 78 [super startTrackingAt:startPoint | 81 [super startTrackingAt:startPoint |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 // which relies on the "published" defaults. | 209 // which relies on the "published" defaults. |
| 207 - (void)resetToDefaults { | 210 - (void)resetToDefaults { |
| 208 [self setEnableClickHold:NO]; | 211 [self setEnableClickHold:NO]; |
| 209 [self setClickHoldTimeout:0.25]; | 212 [self setClickHoldTimeout:0.25]; |
| 210 [self setTrackOnlyInRect:NO]; | 213 [self setTrackOnlyInRect:NO]; |
| 211 [self setActivateOnDrag:YES]; | 214 [self setActivateOnDrag:YES]; |
| 212 } | 215 } |
| 213 | 216 |
| 214 - (BOOL)shouldExposeAccessibilityShowMenu { | 217 - (BOOL)shouldExposeAccessibilityShowMenu { |
| 215 return (enableRightClick_ || (enableClickHold_ && clickHoldTimeout_ > 0.0)) && | 218 return (enableRightClick_ || (enableClickHold_ && clickHoldTimeout_ > 0.0)) && |
| 216 clickHoldAction_ && clickHoldTarget_; | 219 accessibilityShowMenuAction_ && accessibilityShowMenuTarget_; |
| 217 } | 220 } |
| 218 | 221 |
| 219 @end // @implementation ClickHoldButtonCell (Private) | 222 @end // @implementation ClickHoldButtonCell (Private) |
| OLD | NEW |