Drag and Drop to Item in List Field

J. Landman Gay jacque at hyperactivesw.com
Thu Nov 18 21:27:41 CST 2010


On 11/18/10 6:41 PM, Bill Vlahos wrote:
> Getting closer now.
>
> If I put the following script in the source list field the correct text is sent in the drag.
> on mouseDown
>     set the dragData["text"] to the selectedText
> end mouseDown
>
> Target field script hilites the correct line in the list
> on dragMove
>    set the hilitedLines of me to (word 2 of the mouseLine)
> end dragMove
>
> However, if I also put this script in the target field script nothing happens:
> on dragDrop
>     put the dragData["text"]
>     pass dragDrop
> end dragDrop
>
> What I need is the dragged text and the target field line. I believe I can only get that from the target field not the source field but I can't figure out how.

Add a "dragEnter" handler to the target field:

on dragEnter
   set the dragAction to "copy" -- there are other options
end dragEnter

on dragMove
   set the hilitelines of me to (word 2 of the mouseline)
end dragMove

on dragDrop
   put the dragData["text"}
   pass dragDrop
end dragDrop

As is, the dragdrop handler just puts the text into the message box. If 
you want it dropped into the field, supply a position, like "put the 
dragData["text"] & cr before the mouseline".

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list