Showing/Hiding Images on mouseLeave...

Terry Judd tsj at unimelb.edu.au
Wed Nov 13 23:36:01 EST 2002


How about using a referenced image control and change the fileName of 
the image to reflect the different states? I tried several approaches 
using separate object and like you couldn't get any of them to work 
satisfactorily (although I was using  buttons rather than images for 
testing). Placing the mouseLeave handler in the 'idle' object and 
sending a message to it from the 'over' object worked inconsistently. 
The other approach I tried was to group the objects and place all the 
handlers in the group's script - seemed to work as intended for a few 
mouseEnters and mouseLeaves but then descended into some sort of 
hyperactive state switching that eventually locked out (temporarily) 
any mouse activity (command "." seemed to do the trick).


>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...


-- 
Dr Terry Judd
Biomedical Multimedia Unit
Faculty of Dentistry Medicine & Health Sciences
The University of Melbourne
Parkville VIC
Australia



More information about the use-livecode mailing list