drag & drop issue

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
user#606
Posts: 217
Joined: Sun Jan 27, 2008 12:25 pm
Contact:

drag & drop issue

Post by user#606 » Thu Mar 21, 2013 7:00 pm

I have set up a simple testbed to achieve the following.

There are two basic text fields, Comment and Path.
Comment is editable, Path is not (locked text).
I want to drag a file from explorer into the comment field
upon dropping, I want the Comment field contents copied into the Path Field.
Then the comment field is emptied.
The code to do that (I thought) would be:-

Code: Select all

on dragDrop
     put field "Comment" into field "Path"
  put empty into field "Comment" 
     pass dragdrop
end dragDrop
according to the dictionary.

The problem is, file path does not show in either field. They are both blank and the insertion point blinks in the Comment field.

If the code is removed, the drag and drop puts the file path correctly into the Comment field, but obviously, nothing else happens.

Where have I gone wrong?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: drag & drop issue

Post by dunbarx » Thu Mar 21, 2013 8:45 pm

Hi.

Make sure the global "dragAction" property is set to "copy"

I made two fields as you did, and just as a test, a third field for source text. In that source field I had:

Code: Select all

on dragEnd
   put fld "path" into fld "comment"
end dragEnd
This works.

I could not get the "dragDrop" message to work properly, though, but I will play further.

Craig Newman

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: drag & drop issue

Post by dunbarx » Thu Mar 21, 2013 9:55 pm

OK, it turns out that one way to do this is to use the "dragData", not the contents of the target field:

Code: Select all

on dragDrop
   --put me into fld "comment"
   --put me && the dragData into fld "comment"
   put the dragData into fld "comment"
   pass dragDrop
end dragDrop
Why this is so is not clear to me, since the dictionary states that the message is sent after the drop. I assumed this means that the complete augmented text in the target field is live after the drop, but it seems that this is not so. The commented lines above should be tested by you. The second line will load both the old and dragged text, BUT WILL ONLY APPEND. You just want to load the dragText, and that is fine.

I want to find a way to drop the dragged text anywhere in the target text and then send the whole somewhere else. I suspect I am missing something simple.

Anyone?

Craig Newman

Post Reply