use-revolution digest, Vol 1 #1315 - 11 msgs
Bob Rasmussen
brasmussen at earthlink.net
Sun Apr 27 00:48:01 EDT 2003
Dave Cragg <dcragg at lacscentre.co.uk> wrote:
> A mouseMove event is always sent in combination with (and before) a
> mouseDown event. I think this may be what you are referring to. It's
> been part of the engine behavior as far back as I can remember.
>
> You can check with the following script in a button. Keep the mouse
> still, and then click it. (In fact, there now seem to be two
> mouseMove messages sent prior to a mouseDown.)
>
> local lvEvents
> on mouseUp
> put "mouseUp" & cr after lvEvents
> put lvEvents
> put empty into lvEvents
> end mouseUp
>
> on mouseMove
> if the mouse is down then put "mouseMove" & cr after lvEvents
> end mouseMove
>
> on mousedown
> put "mouseDown" & cr after lvEvents
> end mouseDown
>
> I'm not defending the rationality of this, but one good outcome is
> that it discourages use of "the mouse" function to determine whether
> the mouse is down when you want to track mouse movement.
>
> For those new to the list (this issue crops up regularly), the
> "proper" way is to set a flag (as a script local or custom property)
> on mouseDown and reset it on mouseUp. Then in the mouseMove handler,
> check the state of the flag, and *not* the mouse function.
>
> Cheers
> Dave
I genuinely appreciate the effort Dave, but that's still not the case I
reported. The "mouseMove" message that your example demonstrates does indeed
occur before the "mouseDown". However, the extra one I observed occurred
*after* the "mouseDown" had already executed several statements and before the
remaining statements in the "mouseDown" handler completed. It happened, in
fact, coincident with a "hide" statement *inside* the "mouseDown" handler. I
know this, because my handlers looks something like the following after a few
diagnostic items are added akin to your example:
local lvEvents, mouseIsDown
on mouseDown
put true into mouseIsDown
put "mouseDown enter" & cr after lvEvents
-- several statements, which among other things makes a new group within
an existing group using a "copy" command
put "before hide" & cr after lvEvents
hide anObject
put "after hide" & cr after lvEvents
-- several more statements
put "mouseDown exit" & cr after lvEvents
end mouseDown
on mouseMove h, v
if mouseIsDown then
put "mouseMove <--" & cr after lvEvents
-- several more statements
end if
end mouseMove
on mouseUp
put false into mouseIsDown
put "mouseUp" & cr after lvEvents
put lvEvents
put empty into lvEvents
-- several more statements
end mouseUp
What shows up in the message box is this:
mouseDown enter
before hide
mouseMove <--
after hide
mouseDown exit
mouseMove <--
mouseMove <--
mouseMove <--
mouseUp
Take a look at the third line. I hope this makes my situation clearer now.
Thanks,
RR
More information about the use-livecode
mailing list