Showing/Hiding Images on mouseLeave...
Igor de Oliveira Couto
info at pixelmedia.com.au
Wed Nov 13 20:51:01 EST 2002
Dear Revolution Masters,
I'm trying to implement a simple button that should use 3 different
images: 'idle', 'over' (when the cursor in on top of the button), and
'down' (when the mouse is down on the button).
Because the shape of the button is irregular, and I want the
transparent bits to be ignored for mouse events, rather than specifying
the images as icons in a button control, I used IMAGES. My idea was to
setup the 3 images on a card, on top of each other, and simply
show/hide each one in response to the appropriate mouse events.
So I started by putting the 'idle' image on the card, and then the
'over' image on top of that, making sure the 'loc' properties of both
was exactly the same (ie, they were exactly on top of each other). Each
picture is exactly the same as the other, just using different
colours... Now, I went into the scrip of the 'idle' picture, and typed:
on mouseEnter
show image "over"
hide me
end mouseEnter
Then, I went into the script of the 'over' image, and did the opposite:
on mouseLeave
show image "idle"
hide me
end mouseLeave
Now, what is happening when I use the browse tool is a bit of a puzzle:
it goes like this:
The card is displaying the 'idle' image. I move the cursor into the
image, and presto, I see the 'over' image. I also know that the 'idle'
image HAS been hidden - I can check with the message box...
Now, I slowly move the cursor OUTSIDE the image, and... nothing. The
'over' image behaves as if it has NOT received the 'mouseLeave'
message...
I move the cursor back onto the 'over' image, and move it back out -
now for the second time - and, presto, it works: it hides the 'over'
image and shows the 'idle' image.
The crunch of the matter is: I have to 'leave' the image TWICE for it
to work... EVERYTIME!
All I can deduct is that for some reason, the first time the mouse
leaves the 'over' image, no 'mouseLeave' message is being sent to it!
Only after the cursor has re-entered the image, and then proceeds to
leave again, does it work...
Am I missing something embarrassingly simple? Did I not read the
documentation properly? Is this a behaviour that others have noticed?
Is it a bug?
Any help would be greatly appreciated!
Kind Regards,
--
Igor de Oliveira Couto
----------------------------------
igor at pixelmedia.com.au
----------------------------------
More information about the use-livecode
mailing list