Programmatically change mouse cursor

This seems like a stupid question but I have not been able to find a clear answer anywhere in the documentation or in this forum.

In a Mouse Event attached to an object in perspective (EG OnMouseEnter/OnMouseLeave) how do I set the mouse cursor? I have surmised that I need to import Cursor from java.awt in order to have access to Cursor.getPredefinedCursor(…) and Cursor.getDefaultCursor(), but what do I do with them once I have them?

Note that I need to do this programmatically in order to control the process based on a property of teh object. I can’t see that this aspect can be done via a CSS style on the object.

Those are java cursors for use only in Vision…

Someone else will have to suggest what’s possible in Perspective.

Well that really helps. So now I am more lost that I ever imagined

Change the cursor property in styles dynamically:

I understand how to add a cursor style to an object so that on entry/exit it automatically changes. But my use case requires being able to enable/disable that functionality via a separate property of the object. I can’t see how to do that purely with CSS

If you want to override it, set it to whatever you want.
If you no longer want to override it, set it to the value inherit: inherit - CSS: Cascading Style Sheets | MDN

I understand the concept. It’s mechanics of achieving it that are confusing me.

What does this mean, exactly?

I was assuming you have some (relatively static) object property. When it’s X, Y, or Z, you want to use ‘hand’ as the cursor. When it’s A, B, C, you want to use the default cursor.

As long as the cursor property is set, the web browser will automatically change the cursor when you mouse over.

Yes, but I have a single boolean property that I want to use to control the Hand/Default cursor. What is escaping me is how to set the cursor property based on that boolean. And I still couldn’t see anything from the links you provided.

An expression binding? Add a property below style with the name cursor. Then give it an expression that reads in your boolean property and returns either hand or inherit (or whatever other values):

4 Likes