Mouse messages while down
J. Landman Gay
jacque at hyperactivesw.com
Sat Mar 17 23:15:38 CDT 2007
Sarah Reichelt wrote:
> Thanks Jim & Joe,
> That works OK, using a "repeat while the mouse is down loop" and then
> checking the mouseLoc to see whether it is within the rect of any of
> my 400 buttons each time.
> I thought this sort of polling was not considered a good idea. It
> seems fine on my 2GHz Intel Mac, but I'm not sure how it would go on
> slower machines.
> It still seems odd that I can't get the data I need without having to do
Yeah, bad idea. At least, according to Mr. Raney. Sometimes it's the
only way though.
A more politically correct way is to use a mousemove handler. Set a
script local when the mouse goes down or up. Then use mousemove to check
whether the variable flag is set. If not, pass mousemove. If so, check
the mouse location. Off the top of my head:
put true into sFlag -- or you could use the button ID as the flag
put false into sFlag
on mouseMove x,y
if sFlag <> true then pass mouseMove
repeat with n = 1 to the number of btns
if x,y is within the rect of btn n then
put n into tTarget
I use this method in my Klondike game.
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode