-
-
Notifications
You must be signed in to change notification settings - Fork 477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider adding a drag & drop event #496
Comments
Just an update: It looks like this event has been added, but is only implemented for the |
I've been looking into how to get this working for cocoa. In order to receive drag events, cocoa requires implementing the Once implemented, we will have to register the window as a dragging destination for the specific types of files that we can want to handle (in our case, all of them). To do this, we have to call the registerForDraggedTypes method on our window after we have created it and ensured that it is // Register the window as a dragging destination for creating `DroppedFile` events.
msg_send![*window, registerForDraggedTypes:NSArray::arrayWithObject(nil, appkit::NSFilenamesPboardType)]; |
The cocoa API supports handling multiple dropped files at once. When this occurs, we could either:
The second option might be useful for applications that need to know when multiple files are dropped at once though would be a breaking change. The first option is probably simplest to implement in the meantime. |
Add missing "Types for Standard Data" constants. This adds bindings to cocoa's "Types for Standard Data". I believe these are necessary for registering an `NSDraggingDestination` as a receiver for certain kinds of data types. Here are the cocoa references for: - [Types for Standard Data (OS X v10.6 and later)](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSPasteboard_Class/#//apple_ref/doc/constant_group/Types_for_Standard_Data_OS_X_v10.6_and_later_) - [Types for Standard Data (OS X v10.5 and earlier)](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSPasteboard_Class/#//apple_ref/doc/constant_group/Types_for_Standard_Data_OS_X_v10.5_and_earlier_) Relevant to rust-windowing/glutin#496 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/133) <!-- Reviewable:end -->
As a side note, Win32 also supports the event of many files at once (and that's what's used in my impl), however I still opted for triggering many events, seems less intrusive imo. |
It is possible to support more advanced drag and drop, where the window receives notification of the thing being dragged onto it before it is dropped. This allows for visual feedback to be displayed to the user, such as displaying where the dropped thing will be inserted or whether dropping is allowed. https://msdn.microsoft.com/en-us/library/windows/desktop/bb776905(v=vs.85).aspx |
Also for the record the current Windows implementation only accepts paths that can fit in |
Closing for rust-windowing/winit#44 |
GLFW as of 3.1 provides a callback to queue dropped files and afaik SDL2 also has such event.
The text was updated successfully, but these errors were encountered: