Mouse messages while down
J. Landman Gay
jacque at hyperactivesw.com
Sun Mar 18 00:15:38 EDT 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
> this.
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:
local sFlag
on mouseDown
put true into sFlag -- or you could use the button ID as the flag
end mouseDown
on mouseUp
put false into sFlag
end mouseUp
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
exit repeat
end if
end repeat
end mouseMove
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
mailing list