Cross Application Drag Drop

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Vance
Posts: 3
Joined: Mon Oct 03, 2011 6:33 pm

Cross Application Drag Drop

Post by Vance » Tue Dec 18, 2012 10:19 pm

So I have a couple of questions regarding drag and drop. Specifically, I'm building a datagrid form with lines of data. Simple, basically just a field. I want to be able to drag a line from that field and drop it in a Word document (and, eventually, Pages, WordPerfect, etc--but first, just Word).

Now, I can drag and drop the text okay. But what I want to do is process said text (rather, format it) in Word once it is dropped. I want to mark it with a Word field code, to be exact. Can you create a piece of text that contains a Word field code in Livecode, which then would be able to be dropped into Word? I'm not sure the Pasteboard on the mac or whatever Windows uses can carry that cross applications, it's probably a Word only feature. So that means doing it via Applescript or VBA--after the drop happens.

So how can I know what application received my drop? Sending Applescript meant for Word to Pages is definitely a no-no.

Also, a completely unrelated question: Is it trivial to have a longish list of data somewhere and only show a subset of it in a datagrid, depending on various search filters? Like, I want to allow people to only show one category of the data, or to be able to filter it by name, and even to transform the data to "short" form versus a long form, depending on where they are dropping it into Word.

Thanks!

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

Re: Cross Application Drag Drop

Post by Klaus » Tue Dec 18, 2012 10:23 pm

Hi Vance,

1. welcome to the forum! :D

2. Bad news, you cannot control data that is being dragged from Livecode and dropped outside
of the Livecode window/stack nor can you even know where the data will be dropped.


Best

Klaus

Vance
Posts: 3
Joined: Mon Oct 03, 2011 6:33 pm

Re: Cross Application Drag Drop

Post by Vance » Tue Dec 18, 2012 10:48 pm

Hmm. That is bad. However, I was wondering if it could still be done. Here's my thoughts: When you drag something, don't you get a dragEnd message when the drag completes? Even if it is outside the application boundaries? It won't have anything IN the dragDestination property, but won't the dragEnd message fire if it is dropped? Or does the dragEnd message fire regardless of a successful drop or not?

If the message fires at all, then I could probably do some fancy applescripting to talk to word and see if there's a new object that just got placed, and then control Word via applescript to find the new text (that I just dropped) and format it how I need to.

Does that sound reasonable at all?

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

Re: Cross Application Drag Drop

Post by Klaus » Wed Dec 19, 2012 12:09 am

Hi Vance,

I never needed to check if "dragend" is also sent outside of Livecode, so I have no idea.
but why don't you check this by yourself and tell us what you found out? Good luck 8)


Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9663
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Cross Application Drag Drop

Post by dunbarx » Wed Dec 19, 2012 5:58 am

All.

''dragEnd" is sent to LC even if the drag is terminated outside the program. In fact, I dragged some text onto the desktop, where it simply vanished, and the message still was sent. So it is not even necessary that a valid container receive the contents of the drag.

Craig Newman

Einherjar
Posts: 18
Joined: Thu Dec 12, 2013 7:38 pm

Re: Cross Application Drag Drop

Post by Einherjar » Wed Dec 10, 2014 8:53 am

Sorry to bump this thread but I have a question.

Is it possible to drag information from a web browser into a livecode application?

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

Re: Cross Application Drag Drop

Post by Klaus » Wed Dec 10, 2014 1:31 pm

Hi Einherjar,
Einherjar wrote:Sorry to bump this thread but I have a question.
Is it possible to drag information from a web browser into a livecode application?
yes! :D



Check "the dragdata[...]" "on dragenter"!


Best

Klaus

Post Reply

Return to “Talking LiveCode”