Restrict display ...

Eric Chatonet eric.chatonet at sosmartsoftware.com
Tue Apr 17 08:47:04 EDT 2007


Bonjour Jean-Pierre,

Le 17 avr. 07 à 13:56, Jean-Pierre a écrit :

> Is there a way to restrict the display of a moving object in the  
> screen?
> I use white rectangle to mask some aera but it is not easy to  
> handle...

I assume you use the grab command but to master moves you need to run  
your own code mainly based on mouseMove:
Something like the following script in the script of the object you  
want to move might help you:
Note that the "Boundaries" graphic sets the limits the object has not  
to cross.

local lAllowDrag -- script var
---------------------------------
on mouseDown
   put the left of me - the mouseH,the top of me - the mouseV into  
lAllowDrag
end mouseDown
---------------------------------
on mouseMove pX,pY
   if lAllowDrag is empty then exit mouseMove
   -----
   if not IsPosAllowed(the long name of grc "boundaries") then --
     set the screenMouseLOc to globalLoc(the loc of grc "boundaries")
     move me to the loc of grc "boundaries" in 100 milliseconds --  
default location
     exit mouseMove
   end if
   -----
   if the mouse is down then
     -- grabs object:
     set topleft of me to (pX + item 1 of lAllowDrag),(pY + item 2 of  
lAllowDrag)
   end if
end mouseMove
---------------------------------
on mouseUp
   put empty into lAllowDrag
end mouseUp
---------------------------------
on mouseRelease
   mouseUp --
end mouseRelease
---------------------------------
on mouseEnter
   mouseUp --
end mouseEnter
---------------------------------
function IsPosAllowed pRefObj
   if the top of me < the top of pRefObj then return false
   if the bottom of me > the bottom of pRefObj then return false
   if the left of me < the left of pRefObj then return false
   if the right of me > the right of pRefObj then return false
   return true
end IsPosAllowed

Best regards from Paris,
Eric Chatonet.
----------------------------------------------------------------
http://www.sosmartsoftware.com/
eric.chatonet at sosmartsoftware.com/
----------------------------------------------------------------





More information about the use-livecode mailing list