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 meta-issue #720

Open
Osspial opened this issue Nov 20, 2018 · 9 comments
Open

Drag & Drop meta-issue #720

Osspial opened this issue Nov 20, 2018 · 9 comments
Labels
C - needs discussion Direction must be ironed out S - api Design and usability

Comments

@Osspial
Copy link
Contributor

Osspial commented Nov 20, 2018

This is mostly a stub issue to keep track of progress on improvements to the drag/drop API:

  • Dropping lists of files
  • Dropping non-file data
    • Dropping multiple types of data at once (i.e. receiving unformatted text and a formatted, HTML version of that text)
    • Potential datatypes to support:
      • Text
      • HTML
      • Image
      • Audio

I did some research into platform-specific clipboard APIs, and as far as I can tell those are the datatypes that we can probably support across all platforms. I'm hesitant to support audio data sine there seems to be way more variance in how platforms support that than the other datatypes, but from what I've seen most platforms expose it in one way or another.

@maroider
Copy link
Member

A couple of relevant issues have cropped up since this issue was created:

@janus-culsans
Copy link

I think out of all these issues #1550 would be the best starting point, also given that it has the most upvotes.
Essentially this boils down to allowing the cursor position to be read while the mouse is dragging something over the window.
This is completely impossible currently.

@kchibisov
Copy link
Member

kchibisov commented Oct 24, 2022

The mouse coordinates are sent during dnd? You clearly know where file is dropped. It's just not attached to the event itself and is sent separately.

@janus-culsans
Copy link

janus-culsans commented Oct 25, 2022

Why not just tell how it is sent? 😄
CursorMoved is not getting sent, unless bevy uses some very old version of winit or somehow breaks it.
Do you mean DeviceEvent::MouseMotion?

Ah okay, I think I now get it, Cursor... are WindowEvents, so they're "fixed" to the window. When you drop a file into a window, it is inactive and therefore no cursor events fire, only MouseMotion.
That still means #1550 would be greatly appreciated, but I could hack together my own window-relative coordinates on drag.
Probably something like:

  1. save cursor position in a Vec2
  2. when dragging a file and entering the window, HoveredFile is sent
  3. now start adjusting the saved cursor position based on MouseMotion (and clamp to window size)
  4. when window is left while dragging, HoveredFileCancelled is sent / when dragging stops on window, DroppedFile is sent
  5. now stop adjusting the saved cursor position

Oh wait, this doesn't make sense, as you would have to enter the window with your cursor at the exact position you left it :)
So instead, you would have to save the exact position of the cursor even while outside of the window.

TLDR; There is no workaround.

@kchibisov
Copy link
Member

@janus-culsans The cursor position should be broadcasted during the drag and drop. It could be that a particular platform isn't doing so which could indicate a bug. The events are coming not from the drag and drop events, but from Cursor window events, so maybe on a platforms you're testing it's lacking.

@goolord
Copy link

goolord commented Apr 25, 2023

it would be nice to support both drag & drop as a target AND as a source

@janus-culsans
Copy link

@kchibisov if the unsupported platform is MSWindows, okay?

@kchibisov
Copy link
Member

@janus-culsans are you planning to implement something mentioned here?

@janus-culsans
Copy link

@kchibisov I have no knowledge of your internals and no time left, otherwise I would have probably understood your other comments and taken a shot.
I'm sorry, it's just frustrating.

DnD has this weird half-OS half-App-UX problem, which the web standards also could not solve well. Then sometimes you want file DnD, sometimes whiteboardish DnD..
My usecase is also basic drop containers. And I want to show something while hovering over such a container without dropping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C - needs discussion Direction must be ironed out S - api Design and usability
Development

No branches or pull requests

6 participants