Showing/Hiding Images on mouseLeave... IMPROVED

John J. Theobald mailjjt at bellsouth.net
Sat Feb 8 23:18:24 EST 2003


 > John J. Theobald wrote:
 >
 > erik hansen wrote:
 >
 > I simply put a transparent graphic behind my "freeform" shaped
 > button. This graphic extends beyond the borders of my button. I
 > then put this handler in the graphic.
 >
 > on mouseEnter put image "normalstate" into image "goback" end
 > mouseEnter
 >
 > "goback" is the name of my "freeform" button, "normalstate" is the
 > image I want displayed when I do a mouseLeave.  Since leaving the
 > button does not generate a mouseLeave (as you discovered), entering
 >  the transparent graphic DOES generate a mouseEnter and the opportunity
 >  to change the graphic.
 >
 >
 > if the mouse enters the transparent graphic from the card, NOT from
 > freeform btn "goback"?
 >
 > ===== erik at erikhansen.org    http://www.erikhansen.org
 >
 > __________________________________________________ Do you Yahoo!? Yahoo!
 >  Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com
 >

 > _______________________________________________ use-revolution
 > mailing list use-revolution at lists.runrev.com 
http://lists.runrev.com/mailman/listinfo/use-revolution
 >

 >
 >
 >
 > When the mouse enters the transparent graphic from the card, it
 > naturally sends the same "put" to the freeform button.  But, the
 > "normalstate" is what already exists, so it does a "put" that is
 > not needed. In my case I use imported images, so it is a memory
 > copy, no disk I/O. IMHO this is negligible overhead while
 > accomplishing the desired result.  If you wanted to eliminate the
 > "put", just check the state of the image.  Either way, the handler
 > has to do some processing.
 >
 > John Theobald
 >
 > _______________________________________________ use-revolution
 > mailing list use-revolution at lists.runrev.com 
http://lists.runrev.com/mailman/listinfo/use-revolution
 >
 >

Upon further experimentation, I found I did not like the solution I 
provided above because very fast mouse movements over the freeform 
graphic could potentially leave it in an undesireable "state".  I 
imagine this is due to the system mouse polling and it's inability to 
trap events under very fast movement and missing the mouseEnter on my 
surrogate graphic.

So, I decided to write my own "mouseLeave" handler called checkMe for 
the freeform button that is 100% consistent and accurate and involves no 
surrogate graphics.  I submit it as an improved and IMO more elegant 
solution to the mouseLeave issue. Any enhancement suggestions welcomed.

####################################################################
on mouseEnter
  put image "activestate" into me
  send checkMe to me in 10 ticks  # Check the mouseLoc for leave
end mouseEnter

on checkMe
  if within(me, the mouseLoc) then
     send checkMe to me in 10 ticks  # Check back if still within
   else                              # otherwise
     put image "normalstate" into me # back to normal because we left
  end if
end checkMe
####################################################################

I should have done more testing before suggesting my previous solution, 
apologies to the list.


John J. Theobald









More information about the metacard mailing list