General Live Resize control

DunbarX at aol.com DunbarX at aol.com
Thu Jul 16 19:16:04 EDT 2009


A HC-like live resizing routine. (hope this is what you wanted).

It works, but in broad terms, what am I doing that would be considered old 
fashioned? I suspect I am still stuck using repeat loops instead of sending 
queued messages, for example.

Make a small button named "handle". Put this in any object script:

on mouseDown
    repeat while the mouse is down
       show btn "handle"
       put the rect of me into tRect
       put whichCorner(the mouseloc,tRect) into tCorner
       switch
          case tcorner = "TR" --topRight, etc.
             set the rect of me to   item 1 of tRect & "," & item 2 of the 
mouseLoc & "," & item 1 of the mouseLoc & "," & item 4 of tRect
             set the loc of   btn "handle" to item 3 of the rect of me & 
"," & item 2 of the rect of me
             break
          case tcorner = "TL"
             set the rect of me to   item 1 of the mouseLoc   & "," & item 
2 of the mouseLoc & "," & item 3 of tRect & "," & item 4 of tRect
             set the loc of   btn "handle" to item 1 of the rect of me & 
"," & item 2 of the rect of me
             break
          case tcorner = "BL"
             set the rect of me to   item 1 of the the mouseLoc   & "," & 
item 2 of   tRect & "," & item 3 of   tRect & "," & item 2 of the mouseLoc
             set the loc of   btn "handle" to item 1 of the rect of me & 
"," & item 4 of the rect of me
             break
          case tcorner = "BR"
             set the rect of me to   item 1 of   tRect   & "," & item 2 of 
tRect & "," & item 1 of the mouseLoc & "," & item 2 of the mouseLoc
             set the loc of   btn "handle" to item 3 of the rect of me & 
"," & item 4 of the rect of me
             break
       end Switch
    end repeat
    hide btn "handle"
end mouseDown

function whichCorner mLoc,tRect
    switch 
       case abs(item 2 of mLoc - item 2 of tRect) < 15 and abs(item 1 of 
mLoc - item 3 of tRect) < 15 
          return TR
          break
       case abs(item 1 of mLoc - item 1 of tRect) < 15 and abs(item 2 of 
mLoc - item 2 of tRect) < 15 
          return TL
          break
       case abs(item 1 of mLoc - item 1 of tRect) < 15 and abs(item 2 of 
mLoc - item 4 of tRect) < 15 
          return BL
          break
       case abs(item 1 of mLoc - item 3 of tRect) < 15 and abs(item 2 of 
mLoc - item 4 of tRect) < 15 
          return BR
          break
    end switch
end whichCorner

Craig Newman


**************
S T R E T C H  your technology dollars with great 
laptop deals from Dell! 
(http://pr.atwola.com/promoclk/100126575x1223081712x1201714210/aol?redir=http:%2F%2Faltfarm.mediaplex.com%2Fad%2Fck%2F12309%2D81
939%2D1629%2D5)



More information about the use-livecode mailing list