Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,42 @@ - (void)setUserEnabled:(BOOL)userEnabled
}

_userEnabled = userEnabled;

#if !TARGET_OS_OSX
if (!userEnabled) {
[self cancelActivePress];
}
#endif

[self dispatchHoverEventIfNeeded];

if (_isHovered && !_isPressed) {
[self animateHoverState];
}
}

#if !TARGET_OS_OSX
// Ends a press that is in progress when the button gets disabled underneath
// it, so JS receives the press-out
- (void)cancelActivePress
{
if (!self.tracking) {
return;
}

[self cancelTrackingWithEvent:nil];
[self rngh_sendActionsForControlEvents:UIControlEventTouchCancel withEvent:nil];

// No finger lifted, so skip the press-out fade: it would overlap the restyle
// that usually comes with disabling and show as a flash.
[self cancelPendingPressOutAnimation];
[self animateToOpacity:self.restingOpacity
scale:self.restingScale
underlayOpacity:self.restingUnderlayOpacity
duration:0];
}
#endif

- (void)setUnderlayColor:(RNGHColor *)underlayColor
{
_underlayColor = underlayColor;
Expand Down Expand Up @@ -1197,7 +1226,6 @@ - (void)mouseDown:(NSEvent *)event
return;
}


_isTouchInsideBounds = YES;
[self handleAnimatePressIn];
[super mouseDown:event];
Expand All @@ -1208,7 +1236,7 @@ - (void)mouseUp:(NSEvent *)event
if (!_userEnabled) {
return;
}

NSPoint locationInView = [self convertPoint:[event locationInWindow] fromView:nil];
_isHovered = NSPointInRect(locationInView, self.bounds);
[self recordHoverSampleForMouseEvent:event];
Expand All @@ -1224,7 +1252,7 @@ - (void)mouseDragged:(NSEvent *)event
if (!_userEnabled) {
return;
}

NSPoint locationInWindow = [event locationInWindow];
NSPoint locationInView = [self convertPoint:locationInWindow fromView:nil];
BOOL currentlyInside = NSPointInRect(locationInView, self.bounds);
Expand Down Expand Up @@ -1260,7 +1288,7 @@ - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event
if (!_userEnabled) {
return NO;
}

_isTouchInsideBounds = YES;
// A pencil's hover-out arrives just before touch-down but only schedules the
// clear, so `_isHovered` still reflects the open hover. Under Reduce Motion
Expand Down
Loading