Skip to content

Drag & Drop meta-issue #720

Open
Open

Description

@Osspial

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.

Activity

  1. added
    S - api
    C - needs discussion
    on Nov 20, 2018
  2. maroider commented on Jul 15, 2021

    @maroider
    Member

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

  3. janus-culsans commented on Oct 24, 2022

    @janus-culsans

    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.

  4. kchibisov commented on Oct 24, 2022

    @kchibisov
    Member

    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.

  5. janus-culsans commented on Oct 25, 2022

    @janus-culsans

    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.

  6. kchibisov commented on Nov 5, 2022

    @kchibisov
    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.

  7. goolord commented on Apr 25, 2023

    @goolord

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

  8. janus-culsans commented on Nov 21, 2023

    @janus-culsans

    @kchibisov if the unsupported platform is MSWindows, okay?

  9. kchibisov commented on Nov 21, 2023

    @kchibisov
    Member

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

  10. janus-culsans commented on Nov 21, 2023

    @janus-culsans

    @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.

  11. stefnotch commented on Dec 31, 2025

    @stefnotch

    The wasm backend of winit doesn't seem to support file dropping. While it should be straightforward to hook that up around here

    *self.0.on_mouse_release.borrow_mut() = Some(EventListenerHandle::new(
    , it requires an API redesign first. In WASM, we cannot read a PathBuf, and instead get a handle to the file.

  12. kchibisov commented on Dec 31, 2025

    @kchibisov
    Member

    The path stuff will be gone eventually, since it doesn't make much sense in general. It also causes issues on Wayland, because you just get fd most of the time and a bunch of mime types you can pick from, so it'll probably just move to a mimetype + request() on some object.

  13. umajho commented on Jul 22, 2026

    @umajho

    I saw that #4571 has been merged.
    I have not look through the PR in detail, but it seems we now have a DragPosition WindowEvent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C - needs discussionS - api

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions