mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-31 10:20:15 +00:00
Merge pull request #1042 from binl/bl_control_state_fix
Make ASControlState imitate UIControlState
This commit is contained in:
@@ -47,14 +47,27 @@
|
||||
|
||||
[self addSubnode:_titleNode];
|
||||
[self addSubnode:_imageNode];
|
||||
|
||||
[self addTarget:self action:@selector(controlEventUpdated:) forControlEvents:ASControlNodeEventAllEvents];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)controlEventUpdated:(ASControlNode *)node
|
||||
- (void)setEnabled:(BOOL)enabled
|
||||
{
|
||||
[super setEnabled:enabled];
|
||||
[self updateImage];
|
||||
[self updateTitle];
|
||||
}
|
||||
|
||||
- (void)setHighlighted:(BOOL)highlighted
|
||||
{
|
||||
[super setHighlighted:highlighted];
|
||||
[self updateImage];
|
||||
[self updateTitle];
|
||||
}
|
||||
|
||||
- (void)setSelected:(BOOL)selected
|
||||
{
|
||||
[super setSelected:selected];
|
||||
[self updateImage];
|
||||
[self updateTitle];
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ typedef NS_OPTIONS(NSUInteger, ASControlState) {
|
||||
@abstract Indicates whether or not the receiver is highlighted.
|
||||
@discussion This is set automatically when the there is a touch inside the control and removed on exit or touch up. This is different from touchInside in that it includes an area around the control, rather than just for touches inside the control.
|
||||
*/
|
||||
@property (nonatomic, readonly, assign, getter=isHighlighted) BOOL highlighted;
|
||||
@property (nonatomic, assign, getter=isHighlighted) BOOL highlighted;
|
||||
|
||||
/**
|
||||
@abstract Indicates whether or not the receiver is highlighted.
|
||||
|
||||
@@ -46,7 +46,6 @@
|
||||
}
|
||||
|
||||
// Read-write overrides.
|
||||
@property (nonatomic, readwrite, assign, getter=isHighlighted) BOOL highlighted;
|
||||
@property (nonatomic, readwrite, assign, getter=isTracking) BOOL tracking;
|
||||
@property (nonatomic, readwrite, assign, getter=isTouchInside) BOOL touchInside;
|
||||
|
||||
@@ -186,10 +185,6 @@ void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, v
|
||||
// Send the appropriate touch-up control event.
|
||||
CGRect expandedBounds = CGRectInset(self.view.bounds, kASControlNodeExpandedInset, kASControlNodeExpandedInset);
|
||||
BOOL touchUpIsInsideExpandedBounds = CGRectContainsPoint(expandedBounds, touchLocation);
|
||||
|
||||
if (touchUpIsInsideExpandedBounds) {
|
||||
self.selected = !self.selected;
|
||||
}
|
||||
|
||||
[self sendActionsForControlEvents:(touchUpIsInsideExpandedBounds ? ASControlNodeEventTouchUpInside : ASControlNodeEventTouchUpOutside)
|
||||
withEvent:event];
|
||||
|
||||
Reference in New Issue
Block a user