unexpected message passing
pmbrig at gmail.com
Sat Jul 28 00:02:07 EDT 2007
Here's a mystery -- to me, at any rate.
In one of my stacks I have a button that changes its function when
clicked with the optionkey down. To alert the user, I have
mouseEnter, mouseLeave, and mouseMove handlers in the button script
that change the label of the button accordingly. At some point I
noticed that the button label stayed changed after option-clicking it
-- the first thing that happens is an answer dialog, so the user
moves the cursor off the button to deal with that, leaving the button
label in changed mode. I could have made sure to change it back in
the button script, but instead I put a mousemove handler in the stack
script, so that the button would revert to the primary label whenever
the mouse was outside the button.
But then whenever I moved the cursor into the button with the
optionkey down I'd get a rapid flicker between the two labels. I
couldn't for the life of me figure out what was going on, as I do
*not* have a pass mousemove command in the button script. BUT -- when
I either comment out the stack mousemove script or put an empty
blocking mousemove handler in the card script, the flickering stops.
It looks as if the mousemove message is getting passed along the
message hierarchy despite the lack of a "pass" command. How can this be?
I don't have duplicate mousemove handlers in button and stack scripts
-- I checked. I have no relevant frontscripts and I'm using no extra
stacks/libraries. The button is part of a group with
backgroundbehavior set to true (so new cards inherit all controls),
but there's nothing in the group script. It's a simple set-up in
terms of the message path -- or it should be: button -> card -> group
-> stack, except the button handler should block everything higher --
and indeed, I can block it with an empty mousemove handler at the
card level. I looked at the message watcher with mousemove messages
unsuppressed, and every time I moved the mouse one pixel inside the
button rect with the optionkey down the label changes briefly to the
base state then back to the altered state, and I got *two* mousemove
messages: one "mousemove" and one "mouseMove" -- note the capital M.
I guess I don't understand this either. Why two? Does this confirm
the unwarranted passing of the message?
I just tried creating a new empty stack with one button and mousemove
handlers in the button and the stack scripts similar to those
described above, but it doesn't flicker in that simple test stack. I
don't know why it would do so in mine.
I can fix this easily in several ways, but I don't understand what is
Using Studio 2.8.1 build 471 on a Mac iBook G4 with OSX 10.4
Peter M. Brigham
pmbrig at comcast.net
-- PROGRAM, n. A spell cast over a computer allowing
it to turn one's input into error messages.
More information about the Use-livecode