Is it possible to identify when the cursor is within a group?

Cubist at aol.com Cubist at aol.com
Thu Jul 15 21:38:31 EDT 2004


sez bornstein at designeq.com
>Since I'm creating and destroying a variety of groups randomly, I need
>to know which group the mouse is over via some kind of test (the very 
>thing I'm stumped on). Unfortunately, I can't seem to find a way to do
>this if the mouse is simply within the group rect but not over an 
>object. There are some fairly extreme approaches to solving this 
>problem, but I'm hoping for a simple solution.
   Here's a handler which checks which group the mouse may be within, puts 
the name of that group into a custom property of the card, and does this pretty 
close to realtime (20 times per second). Any time you need to know which group 
the mouse is within, you do something like "put the ItzInHere of this card 
into DisGroup" and use it however you like. Will this do what you want?

on InDaGroup
  put the mouseLoc into MousePos
  repeat with K1 = (the number of groups) down to 1
    if MousePos is within the rect of group K1 then set the ItzInHere of this 
card to (the short name of group K1)
  end repeat
  set the ItzInHere of this card to "<< not in any group >>"
  send "InDaGroup" to me in 50 milliseconds
end InDaGroup

   Hope this helps...


More information about the use-livecode mailing list