Drag & Drop of lines within fields

Howard Bornstein howard.bornstein at gmail.com
Wed Aug 3 19:31:22 EDT 2005


On 8/3/05, Scott Rossi <scott at tactilemedia.com> wrote:
> Recently, Ton Kuypers  wrote:
> 
> > I seem to recall that someone created a very nice example of drag &
> > drop of lines in listfields, but I cans seem to find it anymore... I
> > just need to rearrange lines in a field by drag & drop...
> >
> > Could anyone please point me in the right direction or to an example
> > script?
> 

Scott's solution is very elegant. Wilhelm Sanke also came up with a
fairly simple solution that I find I use frequently for this purpose.
His script is below.


on mouseDown
  put word 2 of the clickLine into cl
  set the textstyle of line cl of me to bold
  put item 2 of the mouseLoc into starty
  put the effective textHeight of me into th
  repeat while the mouse is down
    if item 2 of the mouseLoc - starty > (th/2) then
      lock screen
      put cr & line cl of me after line cl + 1 of me
      delete line cl of me
      add 1 to cl
      set the textstyle of line cl of me to bold
      add th to starty
      unlock screen
    else if starty - item 2 of the mouseLoc > (th/2) then
      lock screen
      put line cl of me & cr before line cl - 1 of me
      delete line cl + 1 of me
      subtract 1 from cl
      set the textstyle of line cl of me to bold
      subtract th from starty
      unlock screen
    end if
  end repeat
  set the textstyle of line cl of me to plain
  
end mouseDown

-- 
Regards,

Howard Bornstein
-----------------------
www.designeq.com



More information about the use-livecode mailing list