Selected object "boxes"
DunbarX at aol.com
DunbarX at aol.com
Fri May 7 09:46:38 EDT 2010
These two handlers can be put into the script of any object. It is no big
deal; very straighforward. The commented lines refer to a small btn called
"handle" which I originally had to indicate exactly what you don't want to
see. The handler can certainly be modified and put in the card script to work
on any object. I originally made this to test which messages seemed to be
best suited for the task, like "mouseWithin", "mouseMove" and "mouseStillDown".
This is the "mouseDown" version.
watch line breaks...
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"
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
More information about the use-livecode
mailing list