Dragging from a list field

Trevor DeVore lists at mangomultimedia.com
Mon Aug 29 00:06:09 EDT 2005


On Aug 28, 2005, at 3:06 PM, J. Landman Gay wrote:
>
> Here is the skeleton of what I have, which pretty much works,  
> though I will probably refine it some more. It does require that  
> the user first click on the line to select it before they can drag  
> it. If anyone wants to play with this technique and post  
> improvements, I'm all eyes.
>
> In the list field:
>
> on selectionChanged
>   put the selectedText of me into tTopic
>   if the cCurTopic of me = tTopic then exit selectionChanged
>   set the cCurTopic of me to tTopic -- store for later reference
>   -- display content here, based on selection
> end selectionChanged
>
> on mouseDown
>   if the cCurTopic of me <> the selectedText of me
>   then pass mouseDown -- a new selection; selectionChanged will run
>   set the dragData["text"] to the selectedtext of me -- drag will run
> end mouseDown

Why not something like this.  It will allow for a selection and a  
drag/drop all at once.  I haven't tested it but hopefully it would work.

local sCurrentLine

on mouseDown
     if hilitedLine of me <> sCurrentLine then
         --> DISPLAY CONTENT BASED ON SELECTION

         put hilitedLine of me into sCurrentLine
     end if

     --> CHECK FOR DRAG
     get milliseconds()
     repeat
         if milliseconds() - it > 200 then
             set dragData["text"] to the selectedText of me
             exit repeat
         end if

         if mouse(1) is "up" then exit repeat
     end repeat

     pass mouseDown
end mouseDown

Having the bug fixed where mouseDown code can kill selectionChanged  
would be nice.

-- 
Trevor DeVore
Blue Mango Multimedia
trevor at mangomultimedia.com





More information about the use-livecode mailing list