messages to buttons when the mouse is already down

Ken Norris (dialup) pixelbird at interisland.net
Tue Jan 22 00:56:00 EST 2002


on 1/21/02 4:40 PM, Philip Usher at usher at iqcisp.com wrote:

> on 1/21/02 5:34 PM, "Michael J. Lew" <michaell at unimelb.edu.au> wrote:
> 
>> How can I get the other buttons to hilight without requiring the user
>> to click each individually?
> 
> Michael, try this in the card script
> 
> on mouseDown
> repeat while the mouse is down
> get the mouseLoc
> repeat with n = 1 to the number of btns
> if it is within the rect of btn n then
> set the hilite of btn n to true
> else
> set the hilite of btn n to false
> end if
> end repeat
> end repeat
> end mouseDown
> 
> Cheers,  Philip
------------
When Michael says he has an 'array' of buttons, I assume he means a LOT of
buttons. Your handler will work, uh, sort of, but if there are, say, 100
buttons, it'll have to go through them all to check for a hit before it
makes its decision, so the thing'll react way slow.

He doesn't need an idle handler to poll the mouseloc, either.

I posted what should be the right solution. Check it out.

Best regards,
Ken N.




More information about the use-livecode mailing list