Skip to content

Commit

Permalink
8242577: Cell selection fails on iOS most of the times
Browse files Browse the repository at this point in the history
Reviewed-by: jvos
  • Loading branch information
Jose Pereda authored and Johan Vos committed Apr 20, 2020
1 parent 69e4266 commit 5e9fb82
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ typedef __attribute__((NSObject)) CFMutableDictionaryRef GlassMutableDictionaryR
// touches
@property (nonatomic, strong) GlassMutableDictionaryRef touches;
@property (nonatomic) jlong lastTouchId;
@property (nonatomic) CGPoint beginTouchEventPoint; // coordinates at the beginning of a 'touch' event
// gestures
@property (nonatomic, retain) GlassGestureDelegate *delegate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ @implementation GlassViewDelegate
@synthesize isScrolling;
@synthesize mouseTouch;
@synthesize lastEventPoint;
@synthesize beginTouchEventPoint;


- (void)touchesBeganCallback:(NSSet *)involvedTouches withEvent:(UIEvent *)event
Expand All @@ -116,6 +117,7 @@ - (void)touchesBeganCallback:(NSSet *)involvedTouches withEvent:(UIEvent *)event
if (self.mouseTouch == nil) {
UITouch *touch = [[event allTouches] anyObject];
CGPoint viewPoint = [touch locationInView:self.uiView.superview];
self.beginTouchEventPoint = viewPoint;

self.mouseTouch = touch;

Expand Down Expand Up @@ -144,7 +146,11 @@ - (void)touchesMovedCallback:(NSSet *)involvedTouches withEvent:(UIEvent *)event
// emulate mouse
if (self.mouseTouch != nil && [involvedTouches containsObject:self.mouseTouch] == YES) {
CGPoint viewPoint = [self.mouseTouch locationInView:self.uiView.superview];
[self sendJavaMouseEvent:viewPoint type:com_sun_glass_events_MouseEvent_DRAG button:com_sun_glass_events_MouseEvent_BUTTON_LEFT];
// iOS might send one or more 'NSTouchPhaseMoved', even if the initial event location didn't change.
// This check prevents emulating mouse drag events in such cases
if (!CGPointEqualToPoint(viewPoint, self.beginTouchEventPoint)) {
[self sendJavaMouseEvent:viewPoint type:com_sun_glass_events_MouseEvent_DRAG button:com_sun_glass_events_MouseEvent_BUTTON_LEFT];
}
}
}

Expand Down

0 comments on commit 5e9fb82

Please sign in to comment.