Skip to content
This repository has been archived by the owner on Feb 25, 2025. It is now read-only.

Commit

Permalink
[macOS] Fix FlutterView cursor hit testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
bufffun committed Jun 3, 2024
1 parent ea72558 commit 2f0dd4f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion shell/platform/darwin/macos/framework/Source/FlutterView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ - (void)didUpdateMouseCursor:(NSCursor*)cursor {
// and will not restore it back.
- (void)cursorUpdate:(NSEvent*)event {
// Make sure to not override cursor when over a platform view.
NSView* hitTestView = [self hitTest:[self convertPoint:event.locationInWindow fromView:nil]];
NSPoint mouseLoc = [[self superview] convertPoint:event.locationInWindow fromView:nil];
NSView* hitTestView = [self hitTest:mouseLoc];
if (hitTestView != self) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ - (void)set {

EXPECT_TRUE(hitTestCalled);
// The hit test coordinate should be in the window coordinate system.
EXPECT_TRUE(CGPointEqualToPoint(hitTestCoordinate, CGPointMake(100, 500)));
EXPECT_TRUE(CGPointEqualToPoint(hitTestCoordinate, CGPointMake(100, 100)));
EXPECT_TRUE(cursor.setCalled);
}

Expand Down Expand Up @@ -155,6 +155,6 @@ - (void)set {

EXPECT_TRUE(hitTestCalled);
// The hit test coordinate should be in the window coordinate system.
EXPECT_TRUE(CGPointEqualToPoint(hitTestCoordinate, CGPointMake(100, 500)));
EXPECT_TRUE(CGPointEqualToPoint(hitTestCoordinate, CGPointMake(100, 100)));
EXPECT_FALSE(cursor.setCalled);
}

0 comments on commit 2f0dd4f

Please sign in to comment.