Constraining the pointer within a rect
Jan Sælid
janselid at broadpark.no
Thu Aug 17 20:52:39 EDT 2006
This is just another addition to the suggestions. It is based on Tactile
medias dragsample stack.
Put it inside whatever object you want. Press and hold the mousebutton and
drag the mouse to activate it.
Change the mousedown, mouserelease and mouseup to any other handler you
want.
It is stable but there's still some minor flickering of the mouse cursor. At
least on windows...
----
local constrain,boxL,boxR,boxT,boxB
ON mouseDown
put item 1 of rect of me+4 into boxL -- change number 4 to suit your
needs
put item 3 of rect of me-4 into boxR -- change 4
put item 2 of rect of me+4 into boxT -- change 4
put item 4 of rect of me-4 into boxB -- change 4
put true into constrain
END mouseDown
ON mouseMove x,y
IF not constrain THEN exit mouseMove
set the screenmouseloc to \
globalloc(min(boxR,max(boxL,(x))) & "," &
min(boxB,max(boxT,(y))))
END mouseMove
ON mouseUp
put false into constrain
END mouseUp
ON mouseRelease
mouseUp
END mouseRelease
----
More information about the use-livecode
mailing list