File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,21 @@ - (void)willMoveToSuperview:(UIView *)newSuperview {
4545 }
4646}
4747
48+ - (BOOL )isMouseEvent : (UIEvent *)event {
49+ #if __IPHONE_13_4
50+ if (@available (iOS 13.4 , *)) {
51+ return event.buttonMask != 0 ;
52+ }
53+ #endif
54+ return NO ;
55+ }
56+
4857- (void )touchesBegan : (NSSet <UITouch *> *)touches withEvent : (UIEvent *)event {
58+ if ([self isMouseEvent: event]) {
59+ [self startDragging ];
60+ return ;
61+ }
62+
4963 [currentTouches unionSet: touches];
5064 if (currentTouches.count == 1 ) {
5165 [self firstTouchBegan: touches.anyObject withEvent: event];
@@ -67,6 +81,7 @@ - (void)firstTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event {
6781}
6882
6983- (void )touchesMoved : (NSSet <UITouch *> *)touches withEvent : (UIEvent *)event {
84+ if ([self isMouseEvent: event]) return ;
7085 UITouch *touch = touches.anyObject ;
7186 CGPoint touchLoc = [touch locationInView: self ];
7287 previousTouchLoc = [touch previousLocationInView: self ];
@@ -91,6 +106,10 @@ - (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
91106}
92107
93108- (void )touchesEnded : (NSSet <UITouch *> *)touches withEvent : (UIEvent *)event {
109+ if ([self isMouseEvent: event]) {
110+ [self stopDragging ];
111+ return ;
112+ }
94113 [currentTouches minusSet: touches];
95114 if (currentTouches.count > 0 ) {
96115 return ;
Original file line number Diff line number Diff line change @@ -147,8 +147,10 @@ - (void)setUpPointingDevice {
147147
148148#ifdef __IPHONE_13_4
149149 if (@available (iOS 13.4 , *)) {
150- interaction = [[UIPointerInteraction alloc ] initWithDelegate: self ];
151- [self .view addInteraction: interaction];
150+ if (interaction == nil ) {
151+ interaction = [[UIPointerInteraction alloc ] initWithDelegate: self ];
152+ [self .view addInteraction: interaction];
153+ }
152154 }
153155#endif
154156
You can’t perform that action at this time.
0 commit comments