Page 1 of 1

drag & drop issue

Posted: Thu Mar 21, 2013 7:00 pm
by user#606
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?

Re: drag & drop issue

Posted: Thu Mar 21, 2013 8:45 pm
by dunbarx
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

Re: drag & drop issue

Posted: Thu Mar 21, 2013 9:55 pm
by dunbarx
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