[Use-revolution] Re: Constraining Movement

Sjoerd Op 't Land sjoerdoptland at mac.com
Tue Nov 27 16:33:01 EST 2001

Scott Rossi wrote/ schreef:

> on mouseDown
> set the uAllowDrag of me to true
> end mouseDown
> on mouseMove
> if not the uAllowDrag of me then exit mouseMove
> set the loc of me to \
> min(max(the mouseH,left of img myImg + (width of me/2)),\
> right of img myImg - (width of me/2)),\
> min(max(the mouseV,top of img myImg + (height of me/2)),\
> bottom of img myImg - (height of me/2))
> end mouseMove
> on mouseUp
> set the uAllowDrag of me to false
> end mouseUp
> on mouseRelease
> mouseUp
> end mouseRelease
Very good! Works like a charm!

The only glitch is that when I keep the mouse down and move it outside the
window, release, and come back into the rectangle, the button moves with the
mouse again.

The solution is quite easy: put the following in the stack script:

on mouseLeave
  send "mouseRelease" to button "myButton"
end mouseLeave

Wow! What an example of teamwork: we have a perfect solution in like 5 hours
or so! Great list, great people!

Regards, / Groeten,

More information about the use-livecode mailing list