Reacting to files being dragged over the game window.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

Reacting to files being dragged over the game window.

Post by Kingdaro »

I'd like to streamline the process of song creation for my game, allowing the user to simply drag a music file into the window and putting them in edit mode for the song afterward, a very handy capability osu! has. Would I possible be able to do this with LOVE?
Lapin
Prole
Posts: 19
Joined: Fri Mar 20, 2015 11:53 am

Re: Reacting to files being dragged over the game window.

Post by Lapin »

I guess you'll have to use LuaFFI, and find which function is used in the Windows API.


I found this.


May the force be with you.
User avatar
slime
Solid Snayke
Posts: 3129
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Reacting to files being dragged over the game window.

Post by slime »

LÖVE [wiki]0.10.0[/wiki] will have APIs for this, but 0.9 doesn't.
User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

Re: Reacting to files being dragged over the game window.

Post by Kingdaro »

I'm not too familiar with how FFI works, so I'd rather wait until the next version. Thanks.
User avatar
airstruck
Party member
Posts: 650
Joined: Thu Jun 04, 2015 7:11 pm
Location: Not being time thief.

Re: Reacting to files being dragged over the game window.

Post by airstruck »

slime wrote:LÖVE [wiki]0.10.0[/wiki] will have APIs for this, but 0.9 doesn't.
Added love.filedropped and love.directorydropped event callback functions.
Have you seen how FLTK handles this? There's only one event for the actual dropping (same as the normal paste event) but there are special dnd events that fire first (enter, leave, drag, release) so you can give user visual feedback. Just thought you might be interested to see how they've done it, it works pretty nicely.
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Reacting to files being dragged over the game window.

Post by s-ol »

time thief wrote: Have you seen how FLTK handles this? There's only one event for the actual dropping (same as the normal paste event) but there are special dnd events that fire first (enter, leave, drag, release) so you can give user visual feedback. Just thought you might be interested to see how they've done it, it works pretty nicely.
I would vouch for something a little more like this, maybe have love.datadragged(x, y, data) and love.datadropped(x, y, data).
The return value of datadragged could be used to tell the OS whether dropping is possible.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
slime
Solid Snayke
Posts: 3129
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Reacting to files being dragged over the game window.

Post by slime »

LÖVE relies on SDL for dropped-file events, and SDL's APIs for that are pretty basic right now (even more basic than love.filedropped and love.directorydropped, in fact.)

On OS X you can specify which file types are supported by modifying the LÖVE Info.plist file (although you should only do that for fused games.)
Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests