Dropping file on an LC standalone...

Bob Sneidar bobsneidar at iotecdigital.com
Thu Mar 21 18:46:59 EDT 2024

Does it have to be the icon? If I drag a file onto an app in the Windows Tack Bar it does nothing, even if the file belongs to the app I am dragging the file onto. If however I HOVER on the icon and the app is running, it will bring the app to the front and show the frontmost window if it is hidden.

If I drag the file onto the open Window, the app will open it. Case in point, drag an Excel spreadsheet onto the Excel icon in the task bar. All it will do is add a shortcut to the Excel icon for that file. But launch Excel, open a blank spreadsheet, then drag an excel file onto the icon, hover, then drop onto the blank Excel Spreadsheet. In THIS case it will open the spreadsheet in a new window.

Because of this you may be able to use a Drag / Drop handler in your card script. The caveat is that the card itself will not accept a drag/drop action, but if you drag anything on top of an actual object, THEN the card will get the message.

So to handle this, add an opaque rectangle the size of the card behind everything else (if the opacity is set to 99 it will appear transparent for all intents and purposes). The rectangle (or any other object on the card that doesn’t have a dragDrop handler) will get the message and it will fall through to the card where you can handle it.

This in my card script:

on dragEnter
   set the dragAction to "link" -- for files
   pass dragEnter
end dragEnter

on dragDrop
   put the dragData into tDragData
   set the dragData to empty
   -- do something with tDragData
end dragDrop

On Mar 21, 2024, at 2:48 PM, Paul Dupuis via use-livecode <use-livecode at lists.runrev.com> wrote:

My question is what message is triggered when a file is dropped on a running LC standdalone on Windows

On Windows, if the APP is started by dropping a file on it, the file name is available to any handler in the startup sequence via the $1 special variable. i.e. IF teh variable $1 contains a file name the app was started by someone droping the file on teh app or by double-clicking a file associated with teh app.

On macOS, this is all handled by appleEvents. i.e. if a file is dropped on a LC standalone on macOS that standalone gets an appleEvent message and the parameters of the message can be used to get the file name . This is true on startup (if a file was dropped on the app to start it or an associated file was double clicked to start the app OR on macOS if the app is already running and a file is dropped on its icon, the app gets an appleEvent message.

So, what message does a LC standalone app on Windows get, if it has been running and a file is dropped on its icon? An what is the message path of that message (i.e. is it send to the current card, current stack, the mainstack card, or the mainstack stack?)

Thanks in advance!

More information about the use-livecode mailing list