Skip to content
Open
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 @@ -2323,6 +2323,15 @@ - (void)mouseExited:(NSEvent *)event
[self emitMouseEvent:MouseLeave];
}

- (void)mouseDown:(NSEvent *)event
{
// Accept mouseDown on views that can't move the window, such as Pressable, so it isn't passed on
// to a text field beneath, whose tracking loop would consume the mouseUp the press needs.
if (self.mouseDownCanMoveWindow) {
[super mouseDown:event];
}
}

Comment on lines +2326 to +2334

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment seems a bit too driven by the context window, and I'm worried about the implications of overriding this for other scenarios where we don't want to accept the event. Copilot could you look into both making a newer comment and reviewing whether this is the right fix?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. Accepting it on every view was too broad, and the comment too long. Narrowed in 3302f5f:

- (void)mouseDown:(NSEvent *)event
{
  // Accept mouseDown on views that can't move the window, such as Pressable, so it isn't passed on
  // to a text field beneath, whose tracking loop would consume the mouseUp the press needs.
  if (self.mouseDownCanMoveWindow) {
    [super mouseDown:event];
  }
}
  • Why that flag: Pressable sets mouseDownCanMoveWindow: false on its view. A view that says a press there can't move the window is claiming the press, as AppKit's own controls do. That prop also keeps the view from being flattened.
  • Every other view keeps NSView's default, so window dragging (isMovableByWindowBackground, title-bar areas) and native containers hosting React Native, such as table view cells, see no change.
  • Same pattern as rightMouseDown: and otherMouseDown:, which are accepted only when the view has an onAuxClick handler.
  • Not covered: TouchableOpacity and TouchableHighlight don't set mouseDownCanMoveWindow. I can pass false from them as Pressable does, here or in a follow-up, if you'd like.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested in RNTester-macOS, built from this branch, with real clicks on a button over a TextInput that is being edited:

  • Pressable fires every time.
  • TouchableOpacity and a plain View don't; the click goes to the field. Both keep mouseDownCanMoveWindow YES, so that's main's behaviour.
  • With mouseDownCanMoveWindow={false} passed from TouchableOpacity (a local edit), it fires too, and the plain View is unchanged.

Details are in the description. Happy to add the TouchableOpacity/TouchableHighlight part here if you want it.

- (void)mouseUp:(NSEvent *)event
{
BOOL hasDoubleClickEventHandler = _props->hostPlatformEvents[HostPlatformViewEvents::Offset::DoubleClick];
Expand Down
Loading