# Programmatically change mouse cursor

**URL:** <https://forum.inductiveautomation.com/t/programmatically-change-mouse-cursor/58314>\
**Category:** Ignition\
**Tags:** ignition80, perspective\
**Created:** [April 11, 2022, 5:46pm UTC](https://forum.inductiveautomation.com/t/programmatically-change-mouse-cursor/58314 "2022-04-11T17:46:46Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter](https://avatars.discourse-cdn.com/v4/letter/p/278dde/32.png) [@peter](https://forum.inductiveautomation.com/u/peter)\
**Post date:** [April 11, 2022, 5:46pm UTC](https://forum.inductiveautomation.com/t/programmatically-change-mouse-cursor/58314/1 "2022-04-11T17:46:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 11, 2022, 5:48pm UTC](https://forum.inductiveautomation.com/t/programmatically-change-mouse-cursor/58314/2 "2022-04-11T17:48:01Z")

</div>

Those are java cursors for use only in Vision…

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

---

<div class="post-metadata">

**Author:** ![peter](https://avatars.discourse-cdn.com/v4/letter/p/278dde/32.png) [@peter](https://forum.inductiveautomation.com/u/peter)\
**Post date:** [April 11, 2022, 5:48pm UTC](https://forum.inductiveautomation.com/t/programmatically-change-mouse-cursor/58314/3 "2022-04-11T17:48:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 11, 2022, 5:57pm UTC](https://forum.inductiveautomation.com/t/programmatically-change-mouse-cursor/58314/4 "2022-04-11T17:57:39Z")

</div>

Change the `cursor` property in styles dynamically:

> **[cursor - CSS: Cascading Style Sheets | MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor)**
>
> The cursor CSS property sets the mouse cursor, if any, to show when the mouse pointer is over an element.

---

<div class="post-metadata">

**Author:** ![peter](https://avatars.discourse-cdn.com/v4/letter/p/278dde/32.png) [@peter](https://forum.inductiveautomation.com/u/peter)\
**Post date:** [April 11, 2022, 6:01pm UTC](https://forum.inductiveautomation.com/t/programmatically-change-mouse-cursor/58314/5 "2022-04-11T18:01:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 11, 2022, 6:06pm UTC](https://forum.inductiveautomation.com/t/programmatically-change-mouse-cursor/58314/6 "2022-04-11T18:06:15Z")

</div>

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](https://developer.mozilla.org/en-US/docs/Web/CSS/inherit)

---

<div class="post-metadata">

**Author:** ![peter](https://avatars.discourse-cdn.com/v4/letter/p/278dde/32.png) [@peter](https://forum.inductiveautomation.com/u/peter)\
**Post date:** [April 11, 2022, 6:11pm UTC](https://forum.inductiveautomation.com/t/programmatically-change-mouse-cursor/58314/7 "2022-04-11T18:11:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 11, 2022, 6:17pm UTC](https://forum.inductiveautomation.com/t/programmatically-change-mouse-cursor/58314/8 "2022-04-11T18:17:05Z")

</div>

> [@peter](#):
>
> Note that I need to do this programmatically in order to control the process based on a property of teh object.

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.

---

<div class="post-metadata">

**Author:** ![peter](https://avatars.discourse-cdn.com/v4/letter/p/278dde/32.png) [@peter](https://forum.inductiveautomation.com/u/peter)\
**Post date:** [April 11, 2022, 6:22pm UTC](https://forum.inductiveautomation.com/t/programmatically-change-mouse-cursor/58314/9 "2022-04-11T18:22:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 11, 2022, 6:31pm UTC](https://forum.inductiveautomation.com/t/programmatically-change-mouse-cursor/58314/10 "2022-04-11T18:31:36Z")

</div>

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):

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/8/e80ffe8678a0094777fab9929408a5309fba619c.jpeg)
