dragging FROM LiveCode to external apps

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
stan
Posts: 10
Joined: Thu Jul 17, 2008 10:28 am

dragging FROM LiveCode to external apps

Post by stan » Fri Aug 30, 2024 11:54 am

Dear Livecoders,

I'm building an app that makes use of Livecode's drag & drop facilities. So far, I've successfully built an app that can happily receive stuff dragged onto it from external apps/OS, determine what sort of thing is being dropped and respond accordingly.

However, I can't figure out how to create the reverse of it - i.e. dragging stuff from Livecode to the external environment for processing by the OS or another app. I can successfully get my app to copy various types of control and populate the relevant clipboard data keys and this works fine for the OS and most external apps but I can't figure out how to parallel this copy/paste with drag & drop.

If I drag a control/object from Livecode to somewhere outside the application I don't get the mouse pointer changing to indicate something is being dragged as you might do when dragging from another application even if i set the allowabledragactions on the control appropriately.

Any ideas?

Stan

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: dragging FROM LiveCode to external apps

Post by Klaus » Fri Aug 30, 2024 12:09 pm

Hi stan,
stan wrote:
Fri Aug 30, 2024 11:54 am
...
However, I can't figure out how to create the reverse of it - i.e. dragging stuff from Livecode to the external environment for processing by the OS or another app. I can successfully get my app to copy various types of control and populate the relevant clipboard data keys and this works fine for the OS and most external apps but I can't figure out how to parallel this copy/paste with drag & drop.
you may need to parse the keys of the DRAGDATA array, see dictionary, and act accordingly.
stan wrote:
Fri Aug 30, 2024 11:54 am
...
If I drag a control/object from Livecode to somewhere outside the application I don't get the mouse pointer changing to indicate something is being dragged as you might do when dragging from another application even if i set the allowabledragactions on the control appropriately.
Nut sure, but I'm afraid LC controls are a format tha external apps cannot understand, maybe that is the problem?

Best

Klaus

AndyP
Posts: 634
Joined: Wed Aug 27, 2008 12:57 pm
Contact:

Re: dragging FROM LiveCode to external apps

Post by AndyP » Fri Aug 30, 2024 12:19 pm

A lot depends if the receiving app acceps drag, drag Drop.

Try this experiment. Im on Windows.

Create a field, add some text.

Add this code to the field

Code: Select all

on dragStart
   set the dragData to the selectedText of me
end dragStart
Open Notepad (Windows?)

Select some text from the field, drag and drop into Notepad..

Works here.
Andy .... LC CLASSIC ROCKS!

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: dragging FROM LiveCode to external apps

Post by Klaus » Fri Aug 30, 2024 12:31 pm

On a Mac, Drag'n'Drop of text works without any scripting right out of the box.
I tried from a LC field to "TextEdit.app".

AndyP
Posts: 634
Joined: Wed Aug 27, 2008 12:57 pm
Contact:

Re: dragging FROM LiveCode to external apps

Post by AndyP » Fri Aug 30, 2024 1:19 pm

On a Mac, Drag'n'Drop of text works without any scripting right out of the box.
I tried from a LC field to "TextEdit.app".
yep, just tried on Windows and it works.
Andy .... LC CLASSIC ROCKS!

stan
Posts: 10
Joined: Thu Jul 17, 2008 10:28 am

Re: dragging FROM LiveCode to external apps

Post by stan » Fri Aug 30, 2024 2:14 pm

Thanks for such fast responses!

...and problem solved - setting the dragdata appropriately works - and you can use dragdata["file"] and drag data["image"] to drag files & images as well as text.

Stan

Post Reply