love2d / love

LÖVE is an awesome 2D game framework for Lua.
https://love2d.org
Other
4.7k stars 384 forks source link

Request: Add x and y params to filedropped() and directorydropped() event callbacks #2019

Open AverniteDF opened 5 months ago

AverniteDF commented 5 months ago

filedropped(file) => filedropped(file, x, y) directorydropped(path) => directorydropped(path, x, y)

In most cases the correct coords can be obtained using mouse.getPosition() inside those two callbacks but not always. Consider the case where the Love2D application has halted because it's waiting for a file dialog to close. If you drag a file or directory from the file dialog onto the halted application window and then close the file dialog, the application has no way of knowing the actual coords of the drop because the mouse has possibly moved between the time of the drop and the closing of the dialog. Adding x and y params to those callbacks will allow the programmer to always know the exact location of the drop.

slime73 commented 5 months ago

Unfortunately SDL2 doesn't provide this with the event, but SDL3 will.

EngineerSmith commented 5 months ago

Sounds like my library can jump in here https://github.com/EngineerSmith/isdropping

AverniteDF commented 5 months ago

Perhaps SDL could have an option for automatically bringing a window to the foreground (or making an attempt to) when a drag and drop event occurs (on the release of the mouse button). I think this would be acceptable window behavior (ie. not focus-stealing). Maybe also have an option for bringing the window to the foreground when a mousewheel event occurs. These options could be set with a call like SDL_SetWindowForeground(SDL_DROPFILE | SDL_MOUSEWHEEL) or something better.