Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Any way for a file drag and drop ?
- - By bestguigui Date 2016-06-20 13:36
Hi guys,

would you know any way to allow drag and drop of FILES to a Gosu::Window ?

I'm not talking about moving an object inside the window (like a Gosu::Image), but really any file that would be taken from the file explorer and draged into the Gosu::Window.

Thanks a lot :)
Parent - - By jlnr (dev) Date 2016-06-20 19:37 Edited 2016-06-20 19:49
There is an SDL event we could use for this: https://wiki.libsdl.org/SDL_DropEvent

...but I would still prefer it if a Ruby GUI toolkit finally emerged that handled all of this for us :(

If you only need to do this on Windows, you can probably use the funky win32-api gem to install a hook of type WH_CALLWNDPROC:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms644990(v=vs.85).aspx

And then when you receive the WM_DROPFILES message, you need to call the Drag* functions to figure out the filename:
https://msdn.microsoft.com/en-us/library/windows/desktop/bb774303(v=vs.85).aspx

It will be either easy or hard depending on how familiar you are with this gem :)
https://github.com/cosmo0920/win32-api

Edit: It turns out that the DragQueryFile function is already defined in this companion gem:
https://github.com/cosmo0920/windows-pr/blob/master/lib/windows/shell.rb#L141

And here is someone who has successfully used SetWindowsHookEx with the win32-api gem:
https://github.com/ffi/ffi/issues/283#issuecomment-24902987
Parent - By bestguigui Date 2016-06-21 18:37
That is a great reply ! Thanks, I'll try those :)
Up Topic Gosu / Gosu Exchange / Any way for a file drag and drop ?

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill