Skip to content

Conversation

gicha
Copy link

@gicha gicha commented Sep 16, 2025

Problem

The desktop_drop plugin was blocking mouse events for native PlatformView components in macOS Flutter applications. This occurred because the DropTarget view was overlaying the entire screen and intercepting all mouse events, preventing interaction with platform views.

Solution

Modified the native macOS implementation to properly handle mouse event forwarding while preserving drag & drop functionality:

Key Changes:

  • Enhanced hitTest handling: Override hitTest(_:) to forward mouse events down the responder chain when not handling drag operations
  • Drag state tracking: Added isDragging variable and isDragEvent(_:) method to accurately determine when to handle events
  • Mouse event forwarding: Override all mouse event handlers (mouseDown, mouseUp, mouseDragged, mouseMoved, rightMouseDown, rightMouseUp) to forward events to the next responder when not in drag mode
  • Proper drag completion: Added draggingEnded(_:) method and reset state in all drag completion methods
  • Visual improvements: Made DropTarget transparent for better compatibility with other views

Technical Details:

  • Events are only intercepted during actual drag operations
  • All other mouse events are passed through to underlying views
  • Platform views can now receive and handle mouse events normally
  • Drag & drop functionality remains fully intact

Testing

  • Drag & drop functionality works correctly
  • Platform views respond to mouse events
  • Various interaction types work (clicks, dragging, context menus)
  • No regression in existing functionality

Impact

This fix resolves the blocking issue while maintaining full drag & drop capabilities, allowing seamless integration with native platform views in macOS Flutter applications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant