Fading Graphic Elements On Mouse Hover


#1

Hi!

I’m trying to get an element to become highlighted over time when the mouse hovers over it, and fade back when the mouse isn’t on it. I’ve gotten the element to highlight when the mouse moves over it, but when I move the mouse off, the element wont un-highlight.

Right now the way I have it set up is I’ve implemented the drawRotarySlider class. When the slider detects the mouse is over it a variable rises(which increases the alpha of the highlight). When it detects no mouse - the alpha variable decreases.

I know it’s not working because this function isn’t being called on every graphics cycle, but I’m not sure how to fix it.

Sorry if this is a simple question - still trying to learn everything. Thanks for the help!


#2

Perhaps check out the ComponentAnimator source code to see how that’s implemented.

Rail


#3

Perhaps that could be a nice feature request?
It could be useful if ComponentAnimator could fade a component’s colour, given a ColourId, a startColour and endColour.
(hover your mouse over different tabs in Chrome to see a use case)