Showing/Hiding Images on mouseLeave...

Igor de Oliveira Couto info at pixelmedia.com.au
Thu Nov 14 16:22:01 EST 2002


Dear Revolution Folks,

Thank you all very much for your suggestions, re: problem with 
mouseLeave/mouseEnter messages not being sent to an object if the 
object is hidden while mouse is over it. Comments so far:

 From Terry Judd:
> Igor - How 'odd-shaped' are the non transparent parts of your images? 
> Could you get away with placing a 'transparent' polygon grc over the 
> top of the lot and putting your handlers in that? Not very elegant 
> but...
>

 From Scott Rossi:
> Better would be to get in the habit of using a transparent object to 
> manage
> display of other objects/images, or display images via a button.

and further:
> Then a transparent graphic object could be used to trap mouse events 
> (with
> the image positioned behind it).

The idea behind my application is that users will be able to design 
their own interfaces - i.e., create 'skins' for the application! The 
shape of any buttons therefore, will be up to the user to determine- I 
cannot predict what they will be. Having the image that represents the 
button as an irregular shape (let's say, an 'ink splatter' shape) and 
having the clickable area over is as a rectangle or oval does not seem 
to me to be a very elegant programming solution that we should be 
striving to adopt. It also seems to me that the 'image' control in 
Revolution was designed specifically for that purpose - when irregular 
clickable areas are required.

The crunch of the problem here, however, as pointed out by Rob Cozens, 
is not related to what areas of the image button end up being 
'clickable' or not. The issue here has to do with showing/hiding 
objects, and what messages are passed to objects when they are 
shown/hidden underneath the cursor...

 From Jan Schenkel:
> Or you could have it all handled with a single button,
> no scripting required:
> - import the graphics
> - set its 'icon' to the "idle" graphic
> - set its 'armedIcon' to the "over" graphic
> - set its 'autoArm' property to true.
>

The reason why I chose the 'image' rather than the 'button' object, was 
precisely because after following discussions in this list, I learned 
that the while the 'button' object can display transparent icons, it 
retains a 'rectangular' clickable area - which is not wanted here, as 
some of the buttons designed by users will undoubtedly overlap each 
other!

> Easiest solution would be to stick with a 'one image,
> many pictures' approach, and handle all the messages
> from within a single object, setting the fileName to
> the different states.

Yes, indeed! If I could only refer to images INSIDE the stack, instead 
of having to use EXTERNAL references, this could perhaps work... See, 
the 'skin' file has to be a self-contained entity - ie, it has to have 
all the images that the user needs INSIDE it. Having your skin file 
refer to 30-odd external image files makes for a very unpractical way 
for users to share their skins!

 From Rob Cozens:
> Back to your main issue--I can tell you what I think is happening; but 
> none of the workarounds I have tried fix it:  Image "idle" is not 
> getting a mouseLeave message until the mouse leaves and reenters image 
> "over". There is no mouseLeave message sent to image "over" (I guess 
> RunRev thinks the mouse is still within image "idle") until you exit 
> "over" and reenter it, at which point mouseLeave is sent to "idle" and 
> mouseEnter is sent to "over".  I've tried specifically sending 
> mouseLeave & mouseEnter to the images and clicking outside image 
> "idle" before hiding it; but I still get no message the first time the 
> mouse leaves "over".
>
> Perhaps the MC engine needs to update its current control status when 
> an image is hidden?

I must admit, I had reached the same conclusion, and tried the same 
technique (sending mouseEnter/mouseLeave messages to the appropriate 
objects from inside my script), and observed the same results (ie, 
zilch difference). I have to confess, this is quite disappointing...

I agree wholeheartedly with you: perhaps this is an oversight with the 
Revolution engine design, and if that is the case, I sure hope that it 
will be fixed in version 2.0... It should not be terribly hard to 
implement: if the cursor in within an object's clickable area when it 
receives a 'hide' message, the object should be sent a 'mouseLeave' 
message. Conversely, if when an object receives a 'show' message it 
appears with its clickable area right underneath the cursor, it should 
receive a 'mouseEnter'  message.

Is anyone able to tell us whether this bug has been previously 
reported, and whether it is being addressed in version 2.0?

Many thanks to all, for your interest and your kind suggestions.

Kind Regards,
--
Igor de Oliveira Couto
----------------------------------
igor at pixelmedia.com.au
----------------------------------




More information about the use-livecode mailing list