Skip to content

Commit

Permalink
Update hover and periodic delay.
Browse files Browse the repository at this point in the history
  • Loading branch information
avaidyam committed Dec 21, 2012
1 parent 58bcdf5 commit 35a16ad
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
5 changes: 5 additions & 0 deletions lib/UIKit/TUIControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ typedef enum TUIControlState : NSUInteger {
// action has been finalized. The default value is NO.
@property (nonatomic, assign, getter = isContinuous) BOOL continuous;

// If a control's .continuous property value is set to YES, the
// .periodicDelay property corresponds to the periodic delay
// between each sent action. The default value is 75ms (0.075 seconds).
@property (nonatomic, assign) NSTimeInterval periodicDelay;

// These methods should be used to react to a state change.
// The default method implementation does nothing, but if you
// are subclassing a subclass of TUIControl, such as TUIButton,
Expand Down
27 changes: 9 additions & 18 deletions lib/UIKit/TUIControl.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ @implementation TUIControl

- (id)initWithFrame:(CGRect)rect {
if ((self = [super initWithFrame:rect])) {
self.periodicDelay = 0.075f;
self.targetActions = [NSMutableArray array];
self.accessibilityTraits |= TUIAccessibilityTraitButton;

[[NSNotificationCenter defaultCenter] addObserverForName:NSControlTintDidChangeNotification
object:nil queue:nil
usingBlock:^(NSNotification *note) {
[self systemControlTintChanged];
}];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_controlTintUpdated:)
name:NSControlTintDidChangeNotification
object:nil];
}

return self;
Expand All @@ -76,6 +76,10 @@ - (void)dealloc {

#pragma mark - Control State and Notifications

- (void)_controlTintUpdated:(NSNotification *)note {
[self systemControlTintChanged];
}

- (void)systemControlTintChanged {
if (self.animateStateChange) {
[TUIView animateWithDuration:0.25f animations:^{
Expand Down Expand Up @@ -172,12 +176,6 @@ - (void)mouseDown:(NSEvent *)event {
return;
[super mouseDown:event];

// The mouseExited: and mouseEntered: methods are swallowed.
if ([self eventInside:event]) {
_controlFlags.hover = 0;
[self sendActionsForControlEvents:TUIControlEventMouseHoverEnded];
}

BOOL track = [self beginTrackingWithEvent:event];
[self applyStateChangeAnimated:self.animateStateChange block:^{
if (track && !_controlFlags.tracking)
Expand Down Expand Up @@ -225,13 +223,6 @@ - (void)mouseUp:(NSEvent *)event {
return;
[super mouseUp:event];

// The mouseExited: and mouseEntered: methods are swallowed.
if ([self eventInside:event]) {
_controlFlags.hover = 1;
[self sendActionsForControlEvents:TUIControlEventMouseHoverBegan];
[self setNeedsDisplay];
}

if (_controlFlags.tracking) {
[self endTrackingWithEvent:event];

Expand Down

0 comments on commit 35a16ad

Please sign in to comment.