reordering lists

Bruce Lewis bruce at lewiscoll.com
Sun Feb 24 08:59:01 EST 2002


>Has anybody scripted drag-reordering of lists?
>
>martin baxter
>

Martin,

The following is my technique for reordering in HyperCard and also for
moving from field to field on a single card. This is my to do list (in
various categories), calendar and generally where I spend most of my life.
It shows a btn "Outliner" that is just a grey line to show where the line
will go after the mouse is released.

I imagine this will work in Revolution, but no doubt it can be done much
more easily. Redoing it is on my list. It has evolved over almost 15 years,
so on looking at it I can see improvements even within HyperCard. However,
on today's machines it moves at the right speed, so there was little
incentive to improve it.

I use several HyperCard windowscripts in the same stack, but was not aware
of the functionality you referred to.

on mousedown
  --major revision of card & this script June 16, 1997
  --flds are 15 points per line
  --height of flds is multiple of 15 + 8 and 13 from top  & 7 between flds
  --  major revision April 20, 1998 to use "is within" and to do heights
auto -- change heights

  global activeFld,wdsTBmoved
  if hilite of bg btn "Re-order" is true then  --set up initial values
    put empty into activeFld
    put 0 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
        if activeFld is  3
        then
          put 10 into ht
        else
          put 15 into ht
        end if
        set the loc of cd btn Outliner to the mouseh,((trunc((the
mouseV)/ht)) * ht +4)
        localize
        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

      --final location has been fixed, therefore:
      --   subtract top of  fld less 15
      lock screen
      hide cd btn Outliner
      if activeFld is not empty  --if it is empty nothing happens
      then
        put top of cd btn Outliner - top of background field activeFld +
(2*ht) into extra --item 2 of the loc

        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"
            put 1 into plainAdjustFactor
          else
            do "delete tbMoved"
            put wdsTBmoved & return before line MoveToLine of bg fld activeFld
            put 0 into plainAdjustFactor
          end if
        else
          put wdsTBmoved & return before line MoveToLine of bg fld activeFld
          put 0 into plainAdjustFactor
          if last word of tbMoved is not 3 and activeFld is not 3 --calendar
          then
            do "delete tbMoved"
          end if
        end if
        repeat while last char of bg fld activeFld is return
          delete last char of bg fld activeFld
        end repeat

      end if
    end if

    if activeFld is 3 --calendar
    then
      set textstyle of line (MoveToLine-plainAdjustFactor) of bg fld
activeFld to plain
    end if
    set dontWrap of background field "Appointments" to false

  end if
end mousedown

on localize
  --  major revision April 20, 1998 to use "is within"
  global activeFld
  if the mouseloc is within the rect of bg fld list
  then
    put "1" into activeFld --list
  else
    if the mouseloc is within the rect of bg fld Av
    then
      put "10" into activeFld --Av
    else
      if the mouseloc is within the rect of bg fld phone
      then
        put "6" into activeFld --phone
      else
        if the mouseloc is within the rect of bg fld short
        then
          put "7" into activeFld --short
        else
          if the mouseloc is within the rect of bg fld sec
          then
            put "8" into activeFld --sec
          else
            if the mouseloc is within the rect of bg fld "Appointments"
            then
              put "3" into activeFld --Calendar
              set dontWrap of background field 3 to true
            else
              if the mouseloc is within the rect of bg fld Waiting
              then
                put "9" into activeFld --Waiting
              else
                put empty into activeFld
              end if
            end if
          end if
        end if
      end if
    end if
  end if
  -- put activeFld
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 Use-livecode mailing list