Drag & drop lines between list fields
Jim Ault
jimaultwins at yahoo.com
Wed May 18 06:43:20 EDT 2011
How would the dragDrop handler know the value of tLine?
Also, it seems like 'me' has two different meanings in the dragDrop
handler.
Try this for adding lines to fields that may be empty or need a
return, etc:
put cr & line 1 of tDraggedArray & cr after me
filter me without empty
You also might consider with the syntax
if tParameter is among the lines of the dragDestination then
Hope this helps,
Jim Ault
Las Vegas
On May 18, 2011, at 3:18 AM, Keith Clarke wrote:
> Hi folks,
> To help with some XML file analysis, I've created a pair of list
> fields that display the current node's children. The 'left' field is
> filled with all the child nodes and I filter this list down to just
> the nodes I will investigate further, by dragging into the 'right'
> list the nodes I will ignore.
>
> I thought I'd use this opportunity to learn about drag & drop, so
> the script below sits in each field and allows me to move fields
> back and forth between 'monitor' and 'ignore' lists - well, nearly!
> It's working but in an overall 'copy' mode - not 'move'.
>
> My problem is with the 'line -3' which should check that the drop
> was successful and then delete the line from the source field.
>
> Any clues as to what I'm doing wrong?
>
> /*
> Drag and drop control for managing parameters between 'Monitor' and
> 'Ignore' lists
> */
> on dragStart
> ---Start dragging a Parameter
> put the hilitedLine of me into tLine --a line number reference and
> not the text
> put the line tLine of me into tParameter --gets the text from the
> referenced line number
> set the allowableDragActions to "move"
> set the dragAction to "move"
> set the dragData["text"] to tParameter --creates the 'payload' for
> the drag & drop action
> pass dragStart
> end dragStart
>
> on dragEnter
> --Enable as a receiving field
> set the dragAction to "copy"
> pass dragEnter
> end dragEnter
>
> on dragDrop
> --Put some dragsource logic in here - exit if dragSource is not
> the expected field or the dragData payload is empty
> --Deposit the drag 'payload'
> put the dragData["text"] into tDraggedArray
> if me is not empty then put return after me --adds a return after
> the last item when the destination list is not empty
> put line 1 of tDraggedArray after me --adds the Parameter to the
> list
> sort lines of me --sorts a-z
> if the dragDestination contains tParameter then delete line tLine
> of me
> pass dragDrop
> end dragDrop
>
> Oh, and a minor point - dragAction is set to 'move' but I get the
> OSX 'plus' icon attached to the drag action, which implies copy?!?
More information about the use-livecode
mailing list