Skip to content
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

Drag&Drop API / HoveredFile, DroppedFile #1550

Open
dhardy opened this issue Apr 29, 2020 · 7 comments · May be fixed by #4079
Open

Drag&Drop API / HoveredFile, DroppedFile #1550

dhardy opened this issue Apr 29, 2020 · 7 comments · May be fixed by #4079
Labels
S - api Design and usability

Comments

@dhardy
Copy link
Contributor

dhardy commented Apr 29, 2020

This API is too limited in my opinion. In general, one needs at least a coordinate relative to the window and to receive updates when this coordinate changes. In my tests on X11, the app does not receive usual cursor or touch events when a file is hovered, hence the window has no way of determining the current coordinate.

Suggestion: add a "source" parameter to DroppedFile, HoveredFile, and HoveredFileCancelled, and continue to deliver cursor and touch events as normal.

Alternatively, include a coordinate and add a HoveredFileMoved event.

(I have not investigated platform capabilities and don't have a direct use, but wish to add support to KAS, which must determine the widget under the drop.)

@dhardy dhardy mentioned this issue Apr 29, 2020
3 tasks
@ryanisaacg ryanisaacg added the S - api Design and usability label May 16, 2020
@Boscop
Copy link

Boscop commented Mar 14, 2021

I just spend 2 days trying to figure out why my application thinks I dropped the file at a different location than where my mouse pointer is when I drop the file (when I release the mouse button).

It turned out that it's because winit doesn't send any CursorMoved events (nor CursorEntered) before DroppedFile, only immediately after. That's too late :/
My application sees the file get dropped at the location where the mouse was when it was last hovered over the window before leaving the window & dragging the file in (where it was before CursorLeft), which is totally confusing behavior for the user because
this causes the file to get perceived as being dropped into the wrong "drop area" :(

Ideally, winit should send CursorEntered and CursorMoved as soon as the file-dragging cursor enters the window. And even before HoveredFile is sent.

Can you please fix this? :)
This change wouldn't break anything, right?

My use case:
I have different "drop areas" on my UI and I need to detect which one receives the dropped file.
This can only work if I get mouse pos events before DroppedFile.
(In between HoveredFile and DroppedFile, I also want to highlight the drop area that the mouse is currently hovering over (the one that would receive the dropped file if the mouse button was released here), so this also requires getting mouse pos events before DroppedFile.)

@janus-culsans
Copy link

janus-culsans commented Oct 24, 2022

This is a major issue, I can't even think of many usecases where it would help to just have an event for "dragged a file over the window", unless the file can only be put into exactly one place.

Also see #720 (comment)

@kvark
Copy link
Contributor

kvark commented Nov 5, 2023

Unfortunately hitting this as well. I'm working on a scene editor. When dropping a model into the scene, I need to show where it's going to land. This is currently impossible since Winit doesn't communicate the cursor position to me during the drag :(

@daxpedda
Copy link
Member

daxpedda commented Nov 9, 2023

This is similar to #883 and I believe we should also just add mouse position to this event instead of emitting a CursorMoved event right before.

@LinusDikomey
Copy link

I also need the mouse position of dropped files and ideally while moving. I think emitting CursorMoved events would be best since some apps show previews or something similar when a file is hovered over an area. This requires getting updates of the Cursor position continuously and adding a new event just for that probably wouldn't be needed.

@valadaptive
Copy link

Adding myself to the list of people who needs this API. Trying to implement drag-and-drop functionality in an egui app on top of winit and ran headfirst into this issue.

Are there certain platforms for which this is not possible, or is this an artificial API limitation?

@jomala
Copy link

jomala commented Jan 8, 2025

#2615 looks like the key to unlocking this finally. Anything more that can be done to get this moving?

Or are ther other issues that have to be resolved? Better to get #2615 in ASAP than wait for Wayland support, right?

@valadaptive valadaptive linked a pull request Jan 10, 2025 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S - api Design and usability
Development

Successfully merging a pull request may close this issue.

9 participants