Drag-drop image onto app icon?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
thatkeith
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 257
Joined: Mon Mar 01, 2010 7:13 pm
Location: London, UK
Contact:

Drag-drop image onto app icon?

Post by thatkeith » Tue Jun 11, 2019 1:22 am

I have drag and drop working fine for dropping an image into an object in my stack. But is it possible to set things up so I can drag-drop an image onto my standalone icon in the Dock (I'm on a Mac) and have it work just the same?
Senior Lecturer, LCC (University of the Arts London)
Technical Editor, MacUser (1996-2015)
360 VR media specialist

Klaus
Posts: 11207
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Drag-drop image onto app icon?

Post by Klaus » Tue Jun 11, 2019 12:28 pm

Hi Keith,

as far as I remember you need to catch -> on appleEvent
See the dictionary for further infoand an example.

And you may need to modify the pList to include one or more image formats in the list of formats that your app can handle. If not you need to press the ALT and CMD key when dragging an image on your dock icon to "force" the apple event.


Best

Klaus

matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 83
Joined: Sat Apr 08, 2006 7:55 am
Location: Lübbecke, Germany
Contact:

Re: Drag-drop image onto app icon?

Post by matthiasr » Tue Jun 11, 2019 1:02 pm

This is an example script how it will work with the standalone under Mac OS.

Put the following script into the stack script and adjust it to your needs.

Code: Select all

on appleEvent pClass, pEventID, pSender
   
   if pClass is "aevt"  and pEventID = "odoc" then
       
       ## This is an apple event
       ## We request the data about the apple event
       request appleEvent data
      
      put it into tFileName
      ## now do whatever you want....
      ## in this example i am sending upload + the complete path of the dragged file to the card Main.
      send "uploadFile tFilename,tStartup" to card "Main" in 50 milliseconds
    
   end if
   
   pass appleEvent  
end appleEvent

Post Reply

Return to “Talking LiveCode”