Constraining 'grab'

Ken Norris pixelbird at interisland.net
Sun Nov 16 01:55:23 EST 2003


Hi Scott,

> Date: Sat, 15 Nov 2003 19:12:45 -0800
> From: Scott Rossi <scott at tactilemedia.com>
> Subject: Re: Constraining 'grab'
> 
> On 11/15/03 6:38 PM, "Ken Norris" <pixelbird at interisland.net> wrote:
> 
>> In SuperCard I would constrain a 'grab' like this:
>> 
>> grab me within the rect of grc 2
>> 
>> ...in Rev I would say:
>> 
>> ?
> 
> Searching back through the list archives for "constrain", a similar question
> of appears here:
> 
> http://lists.runrev.com/pipermail/use-revolution/2002-March/002682.html
> 
> And the oft-proposed solution follows:
> 
> http://lists.runrev.com/pipermail/use-revolution/2002-March/002686.html
----------
Well, looks like I asked the same Q about 1.5 years ago, which is a little
embarassing. I guess the solution was a little more complicated than I
expected (and still is for that matter), but at least I can understand it a
little better now.

The math makes sense of course, but part of the solution uses "the mouseV"
etc., which I though was frowned upon in Rev/MC:

on mouseDown
  set the hilite of me to true
  # STORE SOME SPECS TO REFERENCE IN THE MOUSEMOVE HANDLER:
  # 1) THE CLICK POSITION
  # 2) THE WIDTH/HEIGHT OF THIS BUTTON
  # 3) THE RECT OF THE CONSTRAINING BOX
  set the uAllowDrag of me to \
      (the mouseH - left of me) & "," & (the mouseV - top of me) & "," & \
      width of me & "," & height of me & "," & \
      rect of grc 1
end mouseDown

...but I guess it's just a 1-time message, so there's no hang time.

Still, could we substitute a 'send in (time)' solution here instead?

I wonder what the chances of getting a constraining rect param option for
the grab command are. Seems like a common enough feature to add; I can
hardly think of a condition where I would _not_ want to constrain it in some
way.

Ken N.





More information about the use-livecode mailing list