Grabbing another grc

Graham Samuel livfoss at
Tue May 6 10:49:01 EDT 2003

I'm trying to pass a 'grab' from one object to another, so that when 
the user drags one object, a second object is the one that moves 
(without the user having to do a 'mouseUp') In the TD, the item for 
'grab' says:

"You can only grab a control when the mouse pointer is within the 
control's rectangle. If the mouse pointer is outside the control when 
the grab command is executed, nothing happens."

The TD entry also **implies** that you can cause the grab to affect a 
different object other than the one with the 'grab' command in it, as 
long as the mouse is within the control's rectangle, but this doesn't 
work. For example, suppose I have two similarly-sized graphics, 
"circle" and "square", and I put the following script into "circle".

   on mouseDown
     set the loc of grc "square" to the loc of me
     hide me -- this is optional and doesn't affect the result
     grab grc "square"
   end mouseDown

nothing happens. OK, so this is how RR works, but my next attempt:

   on mouseDown
     set the loc of grc "square" to the loc of me
     hide me
     repeat while the mouse is down
       set the loc of grc "square" to the mouseLoc
     end repeat
     send "mouseUp" to me
   end mouseDown

Seems kind of clumsy, and I know mouse polling is supposed to be bad 
news. (BTW, I have to send the mouseUp myself because otherwise 
neither grc gets a mouseUp indication).

Can anyone suggest a more elegant solution?



PS I'm using RR 1.1.1 on MacOS 9.2.2.

          Graham Samuel / The Living Fossil Co. / UK & France

More information about the use-livecode mailing list