Dragging Lines in a Field

Bruce Lewis bruce at lewiscoll.com
Sat Apr 20 07:36:00 EDT 2002


>>Does anybody have a solution for dragging lines up and down in a field to
>> resort them?
>>Thanks,

I use the following in HyperCard. It also drags the lines between flds, but
you could easily drop that feature.

on mousedown
  global activeFld
  if hilite of bg btn "Re-order" is true then  --set up initial values
    put empty into activeFld
    put 11 into ht
    put the clickLine into tbMoved
    if tbMoved is not empty
    then
      put value of tbMoved into wdsTBmoved
      set the loc of cd btn Outliner to the mouseloc
      show cd btn Outliner
      repeat until the mouse is "Up"   --move around to determine where
item is going
        set the loc of cd btn Outliner to the mouseh,the mouseV
        localize  --indicates which fld the mouse is in, i.e. the activeFld
        if activeFld is not empty
        then --scrolling
          if the mouseV < (top of bg fld activeFld + 10)  then
            wait 2 ticks
            set scroll of bg fld activeFld to (scroll of bg fld activeFld - 15)
          else if the mouseV > (bottom of bg fld activeFld - 10) then
            wait 2 ticks
            set scroll of bg fld activeFld to (scroll of bg fld activeFld + 15)
          end if
        end if
      end repeat

      lock screen
      hide cd btn Outliner
      if activeFld is not empty  --if it is empty nothing happens
      then
        put item 2 of the loc of cd btn Outliner - top of background field
activeFld + (1*ht) into extra
        put trunc((scroll of bg fld activeFld + extra)/ht) into MoveToLine
        if the last word of tbMoved = activeFld
        then
          if MoveToLine > word 2 of tbMoved
          then
            put wdsTBmoved & return before line MoveToLine of bg fld activeFld
            do "delete tbMoved"
          else
            do "delete tbMoved"
            put wdsTBmoved & return before line MoveToLine of bg fld activeFld
          end if
        else
          put wdsTBmoved & return before line MoveToLine of bg fld activeFld
          do "delete tbMoved"
        end if
        unlock screen
        repeat while last char of bg fld activeFld is return
          delete last char of bg fld activeFld
        end repeat
      end if
    end if
  end if
end mousedown

on localize
  --  major revision April 20, 1998 to use "is within"
  global activeFld
  repeat with i = 1 to the number of bg flds
    if the mouseloc is within the rect of bg fld i
    then
      put i into activeFld
      exit localize
    end if
  end repeat
end localize
-- 
Bruce Lewis
Lewis & Collyer
160 John Street, Suite 401
Toronto, Ontario
Canada  M5V 2E5
(416) 598-4357
FAX (416) 598-1067
bruce at lewiscoll.com
nancy at lewiscoll.com
sandy at lewiscoll.com
joan at lewiscoll.com
eva at lewiscoll.com



More information about the metacard mailing list