Hi Jim,
Thanks for the response - and good points well made. 

I was forgetting that whilst the same script code is common to both fields, at 
any one time, each field's script is only aware of the start or end-point 
handlers of the procedure. The tParameter variable should have been declared at 
script level to make it visible for all handlers in the script (my first 
mistake!) but as it is needed by both start and end fields' scripts, I have 
made it a global.

Thanks also for the tip on adding returns and filtering - and the 'is among 
the...' syntax. I was having lots of fun yesterday working through all the 
mechanisms to check 'is this text in that container' but I had missed this one 
completely.

It's not working but I've a few good tips to run with now.
Best,
Keith..     

On 18 May 2011, at 11:43, Jim Ault wrote:

> 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?!?


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to