Skip to content

Implemented files_dropped_event for macOS#619

Merged
not-fl3 merged 1 commit intonot-fl3:masterfrom
Pewnack:file_dropping
Apr 6, 2026
Merged

Implemented files_dropped_event for macOS#619
not-fl3 merged 1 commit intonot-fl3:masterfrom
Pewnack:file_dropping

Conversation

@Pewnack
Copy link
Copy Markdown
Contributor

@Pewnack Pewnack commented Apr 6, 2026

This is a fix for issue #568

Implemented the files_dropped_event for macOS. It's only triggered for files, not directories. Also returns the dropped_file_bytes same as for linux_x11.

On macOS this only required the implementation of two events :

  • draggingEntered - Triggered when drag 'n drop targets enter the Window and decides if you are going to accept it. Here we check if we are actually dragging file URLs. If not, the drag is not accepted. File URLs also include directories though.
  • performDragOperation - Triggered when the drop takes place. Here we explicitly check if it is files we are dropping. Directories are skipped and will not trigger the files_dropped event.

We also need to tell the view to handle drag 'n drop with a call to registerForDraggedTypes. Without this, the drag 'n drop events are not triggered at all.

When files are dropped we read its bytes for dropped_file_bytes with std::fs::read. Mimicked this from linux_x11.rs.

Tested it on macOS Tahoe 26.4 (currently the latest macOS version) and on the older macOS Monterey 12.7.6.

@not-fl3
Copy link
Copy Markdown
Owner

not-fl3 commented Apr 6, 2026

Thanks for PR!

@not-fl3 not-fl3 merged commit a6e3d78 into not-fl3:master Apr 6, 2026
11 checks passed
@Pewnack
Copy link
Copy Markdown
Contributor Author

Pewnack commented Apr 7, 2026

Thanks for merging!

@Pewnack Pewnack deleted the file_dropping branch April 7, 2026 15:38
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.

2 participants