Constraining the pointer within a rect

Peter T. Evensen pevensen at siboneylg.com
Thu Aug 17 16:20:57 EDT 2006


Perhaps you could just create an object and trap the mouseLeave message and 
move the pointer in that?

At 03:14 PM 8/17/2006, you wrote:
>I found that using a "send in time" structure to check the mouseLoc
>rather than waiting for the mouseMove message was slightly more
>reliable (OSX) and better kept it from going outside the bounding area.
>
>on MouseTrap
>    -- keep the mouse pointer inside the window
>     if the optionkey is NOT "down" then -- but overide this behavior
>with the "optionKey"
>         put item 1 of globalLoc(the mouseLoc) into x
>         put item 2 of globalLoc(the mouseLoc) into y
>         put the top of this stack into tTopEdge
>         put the bottom of this stack into tBottomEdge
>         put the right of this stack into tRightEdge
>         put the left of this stack into tLeftEdge
>         if x < tLeftEdge then put tLeftEdge +1 into x
>         if x > tRightEdge then put tRightEdge -1 into x
>         if y < tTopEdge then put tTopEdge +1 into y
>         if y > tBottomEdge then put tBottomEdge-1 into y
>         set the screenmouseloc to x,y
>     end if
>   send MouseTrap to me in 40 millisec
>end MouseTrap
>
>
>-Scott Morrow
>
>Elementary Software
>(Now with 20% less chalk dust !)
>web     http://elementarysoftware.com/
>email   scott at elementarysoftware.com
>
>-----------------------------------------------------------------
>
>On Aug 17, 2006, at 8:40 AM, Howard Bornstein wrote:
>
>>This script seems to work with adequate performance:
>>
>>on mousemove mh,mv
>>  if the hilite of btn "constrain" is true then
>>
>>    if mh <= the left of fld "container" then
>>      set the screenmouseloc to the globalloc of (the left of fld
>>"container", mv)
>>    end if
>>
>>    if mh >= the right of fld "container" then
>>      set the screenmouseloc to the globalloc of (the right of fld
>>"container", mv)
>>    end if
>>
>>    if mv <= the top of fld "container" then
>>      set the screenmouseloc to the globalloc of (mh,the top of fld
>>"container")
>>    end if
>>
>>    if mv >= the bottom of fld "container" then
>>      set the screenmouseloc to the globalloc of (mh,the bottom of fld
>>"container")
>>    end if
>>
>>  end if
>>end mousemove
>>
>>
>>Note two things:
>>
>>1) The button "Constrain" needs to be within the field "Container"
>>or you'll
>>never be able to get out. :-)
>>
>>2) It is possible to move the mouse out of the rect for brief
>>moments, but
>>then it pops back into the rectangle. I'm assuming it's a function of
>>slipping out between a mousemove scan.
>>
>>
>>
>>--
>>Regards,
>>
>>Howard Bornstein
>>-----------------------
>>www.designeq.com
>>_______________________________________________
>>use-revolution mailing list
>>use-revolution at lists.runrev.com
>>Please visit this url to subscribe, unsubscribe and manage your
>>subscription preferences:
>>http://lists.runrev.com/mailman/listinfo/use-revolution
>
>_______________________________________________
>use-revolution mailing list
>use-revolution at lists.runrev.com
>Please visit this url to subscribe, unsubscribe and manage your 
>subscription preferences:
>http://lists.runrev.com/mailman/listinfo/use-revolution

Peter T. Evensen
http://www.PetersRoadToHealth.com
314-629-5248 or 888-682-4588 





More information about the use-livecode mailing list