Circle with button hover animation


I have a template representing a motor.
Basically, it's a circle with a "M" inside.
The fill colour of the circle is animated using styles.
On click of the circle, it opens a popup windows with motor details.
All this is working correctly.
Now, I would like to add a hover effect on the circle as if it was a button so the user now it is clickable.
I have no idea how to do it properly. I have tried playing with the mouseEntered/Exited events but without result.

I have also tried to use a button and change the back colour but a button cannot be made round.

This is purely cosmetic but I really would like to have that.

Somebody can help me?

Best regards.

edit: Missed the vision tag... Below is answer for perspective.

Use an Element State style class:

You should be able to set the cursor for the circle shape to the hand/finger pointer. Translate the following to jython:

Those are for Perspective. This is a Vision topic.

1 Like

I have a tutorial on how to do this sort of thing in Vision here:

To just change the pointer to cue the user that the object is clickable, the linked solution is way overkill.

1 Like

I guess I misunderstood the question.

Perhaps something like this then?

from java.awt import Cursor

#pick your cursor code
Parsed out of this also way overkill solution. lol

I wasn't clear enough with my demand:
What I would like ideally is to have the circle animate as if it was a button (colour darker on mouse hover).
The mouse cursor change is indeed a solution to signal the user that there is a button here but it's not in line with the behaviour of the standard button.

Why didn't the mouseEntered and mouseExited event handlers work?

In those events use code similar to this to change the color:

from java.awt import Color

or to specify an exact color in the RGBA space

from java.awt import Color

You can also use the Color.darker() and Color.brighter() functions in conjunction with the .getFillPaint() method.

Here is the documentation for PathBasedVisionShapes


This solution works. I wasn't able to do it properly myself previously. But it does work.

This is obviously not exactly the same render as a regular button, but it's enough!


UPDATE: I slightly changed the solution. Now, I use another circle, default invisible, no border, backcolor set to 240,240,240,84 and I display it on mouse enter and hide in on mouse exit. This feel more similar to a regular button.

1 Like