winit icon indicating copy to clipboard operation
winit copied to clipboard

Support for file dragging

Open arguablykomodo opened this issue 5 years ago • 9 comments

winit already has (albeit rudimentary) support for dropping files onto a window, but no way to allow dragging data from a window. As it already supports dropping, I think dragging should also be supported by winit. Being able to drag a file from a winit window is the last missing piece for my usecase of the library.

arguablykomodo avatar Mar 07 '20 02:03 arguablykomodo

Hey I would like this as a feature as well.

toastmod avatar Jul 13 '21 22:07 toastmod

Hey I would like this as a feature as well.

If you're interested in getting the ball rolling on this, then I'd suggest that you look into what APIs we need to use on each platform, and perhaps formulate why this functionality must exist in winit beyond "winit already supports dropping", as neither SDL2 nor GLFW support this (to my knowledge).

maroider avatar Jul 15 '21 09:07 maroider

Hey I would like this as a feature as well.

If you're interested in getting the ball rolling on this, then I'd suggest that you look into what APIs we need to use on each platform, and perhaps formulate why this functionality must exist in winit beyond "winit already supports dropping", as neither SDL2 nor GLFW support this (to my knowledge).

Right, I have a small bit of knowledge on how this works in the windows api though I've never done it successfully in rust. I may try making a fork of winit and implementing it in my own time, probably when I will want to implement it in my own program (soon I hope).

toastmod avatar Jul 15 '21 18:07 toastmod

winit already has (albeit rudimentary) support for dropping files onto a window,

Drop, yes, but DroppedFile and HoveredFile do not report the window-local coordinates and last time I tested cursor locations were not reported while dragging, so it is incomplete.

dhardy avatar Jul 16 '21 09:07 dhardy

@dhardy If it helps to know, the cursor coordinates are reported as a CursorMoved event directly after the DroppedFile event is fired. But at one point I was about to go on here and ask if the coordinates could be passed along with DroppedFile so I understand.

toastmod avatar Jul 20 '21 23:07 toastmod

Looks like the windows crate is finally figuring out COM objects so I might try to add this soon. But where in winit's source is the best place to put a function that initiates a file drag?

toastmod avatar Apr 20 '22 19:04 toastmod

are there any updates regarding this topic?

JumpyLionnn avatar Aug 06 '23 09:08 JumpyLionnn

Any news on this feature?

MartorSkull avatar Jun 02 '24 22:06 MartorSkull

This is now possible in the current state of the windows API for rust. For anyone interested, you are probably best to get the raw window handle from a winit window and use that with the windows API. You will have to manage OLE/COM properly though I believe or your winit event loop might break.

toastmod avatar Jun 04 '24 17:06 toastmod