# Mouse Cursor point to hand change over specific cell?

**URL:** <https://forum.inductiveautomation.com/t/mouse-cursor-point-to-hand-change-over-specific-cell/46851>\
**Category:** Ignition\
**Tags:** scripting, vision\
**Created:** [May 18, 2021, 5:55pm UTC](https://forum.inductiveautomation.com/t/mouse-cursor-point-to-hand-change-over-specific-cell/46851 "2021-05-18T17:55:50Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![dzohner](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@dzohner](https://forum.inductiveautomation.com/u/dzohner)\
**Post date:** [May 18, 2021, 5:55pm UTC](https://forum.inductiveautomation.com/t/mouse-cursor-point-to-hand-change-over-specific-cell/46851/1 "2021-05-18T17:55:50Z")

</div>

Does anyone know a way to force the mouse cursor to change from pointer to hand over specific cells in the power table.

I’m using two columns for navigation. I am trying to get the cursor to change so the operator knows what is clickable vs not.

Any input is appreciated.

Thanks.

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [May 18, 2021, 9:34pm UTC](https://forum.inductiveautomation.com/t/mouse-cursor-point-to-hand-change-over-specific-cell/46851/2 "2021-05-18T21:34:29Z")

</div>

This could have been easy if there were an extension function onMouseMovedCell() on power table. Since each cell has its own event listener, the event handler exposed mouseMoved() won’t be useful so we’re forced to use another approach.  
The fast solution I can think is on a client event script with a fast rate execution of 200 millis or so and dedicated thread.  
The script should look like this:

```auto
def setCursorTable(jtable): 
	from java.awt import MouseInfo, Point, Cursor
	pointerLocation = MouseInfo.getPointerInfo().getLocation() 
	table = jtable.getTable()
	relativeX = pointerLocation.x-table.getLocationOnScreen().x 
	relativeY = pointerLocation.y-table.getLocationOnScreen().y 
	tablePoint = Point(relativeX,relativeY) 
	rowPointIdx = table.rowAtPoint(tablePoint)
	colPointIdx = table.columnAtPoint(tablePoint)
	if rowPointIdx != -1 and colPointIdx != -1:
		#add more column index conditions
        if colPointIdx == 0: #0 index column
			jtable.setCursorCode(Cursor.HAND_CURSOR)
		elif colPointIdx == 1: #1 index column
			jtable.setCursorCode(Cursor.DEFAULT_CURSOR)
	
windowPath = "Main Window" #your windows path where your table is located
tableName = "Power Table" #your table name component
try:
	window = system.gui.getWindow(windowPath)
	jtable = window.getRootContainer().getComponent(tableName)
	setCursorTable(jtable)
except:
	system.util.getLogger('jtableCursor').info('no window opened or not component found.')

```

and this in mouseEntered() event handler power table

```auto
from java.awt import Cursor
event.source.setCursorCode(Cursor.DEFAULT_CURSOR)

```

You should monitor the performance of the client.

---

<div class="post-metadata">

**Author:** ![dzohner](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@dzohner](https://forum.inductiveautomation.com/u/dzohner)\
**Post date:** [May 19, 2021, 10:45pm UTC](https://forum.inductiveautomation.com/t/mouse-cursor-point-to-hand-change-over-specific-cell/46851/3 "2021-05-19T22:45:20Z")

</div>

@jespinmartin1 Thanks for the quick response I will implement this and let you know how it worked. Thanks.

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [May 19, 2021, 11:10pm UTC](https://forum.inductiveautomation.com/t/mouse-cursor-point-to-hand-change-over-specific-cell/46851/4 "2021-05-19T23:10:27Z")

</div>

it works, I did it. Tell me if you need some help.

---

<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:** [May 20, 2021, 3:01pm UTC](https://forum.inductiveautomation.com/t/mouse-cursor-point-to-hand-change-over-specific-cell/46851/5 "2021-05-20T15:01:24Z")

</div>

Potentially easier, probably more performant, would be to return a custom renderer for each cell/column, with the appropriate cursor selected. The tricky part then becomes the actual rendering; [`javax.swing.table.DefaultTableCellRenderer`](https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/javax/swing/table/DefaultTableCellRenderer.html) is just a wrapped JLabel, so it may not have the ‘right’ appearance without further customization.

---

<div class="post-metadata">

**Author:** ![dzohner](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@dzohner](https://forum.inductiveautomation.com/u/dzohner)\
**Post date:** [May 21, 2021, 5:52pm UTC](https://forum.inductiveautomation.com/t/mouse-cursor-point-to-hand-change-over-specific-cell/46851/6 "2021-05-21T17:52:44Z")

</div>

@jespinmartin1

I’m having issues.

I’ve implemented the above script in the local functions under scripting

I put the below code in the mounsEntered() event handler

I adjusted the window path and table name.

I don’t get any error codes of any sort but not cursor change

any ideas I might try?

Thanks again for all your help

---

<div class="post-metadata">

**Author:** ![dzohner](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@dzohner](https://forum.inductiveautomation.com/u/dzohner)\
**Post date:** [May 21, 2021, 5:54pm UTC](https://forum.inductiveautomation.com/t/mouse-cursor-point-to-hand-change-over-specific-cell/46851/7 "2021-05-21T17:54:37Z")

</div>

@paul-griffith thanks for the input. I’ll be honest a bit above my head but I appreciate the response and will put in the time and research into your input thanks.

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [May 21, 2021, 6:55pm UTC](https://forum.inductiveautomation.com/t/mouse-cursor-point-to-hand-change-over-specific-cell/46851/8 "2021-05-21T18:55:04Z")

</div>

Is “local function” equivalent to you to **Client Event Script** with 200ms timer?  
Can you create a new client script with maybe 1sec rate:

```auto
print "I'm a client script"

```

And see the output at the client console?  
Did you changed the colPointIdx Conditions applied to your case?

---

<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:** [May 21, 2021, 8:58pm UTC](https://forum.inductiveautomation.com/t/mouse-cursor-point-to-hand-change-over-specific-cell/46851/9 "2021-05-21T20:58:29Z")

</div>

Eh, my approach doesn’t work anyways; it doesn’t seem to render the different cursor.  
For posterity:

```auto
	if colName == "String Column":
		from javax.swing.table import DefaultTableCellRenderer
		from java.awt import Cursor 
		renderer = DefaultTableCellRenderer()
		renderer.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR))
		renderer.setValue(textValue)
		return {'renderer': renderer}

```

---

<div class="post-metadata">

**Author:** ![dzohner](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@dzohner](https://forum.inductiveautomation.com/u/dzohner)\
**Post date:** [May 21, 2021, 9:27pm UTC](https://forum.inductiveautomation.com/t/mouse-cursor-point-to-hand-change-over-specific-cell/46851/10 "2021-05-21T21:27:32Z")

</div>

@jespinmartin1 Your solution worked I didn’t place your code in the Client Event Script. I put the code in the “Project Library” under scripting.

Thanks for your help and follow up.

---

<div class="post-metadata">

**Author:** ![will\_d](https://avatars.discourse-cdn.com/v4/letter/w/3d9bf3/32.png) [@will\_d](https://forum.inductiveautomation.com/u/will_d)\
**Post date:** [June 14, 2021, 9:09pm UTC](https://forum.inductiveautomation.com/t/mouse-cursor-point-to-hand-change-over-specific-cell/46851/11 "2021-06-14T21:09:56Z")

</div>

For anyone who’s interested, I took a slightly different approach and was able to get things to work in what I believe to be a straightforward, performant way.

NOTE: I make no guarantees about this code. It might have bugs, and it almost surely could be optimized or made more elegant in some way.

I put this class definition in a shared library that happens to be named “Utils” in my project:

```auto
from java.awt.event import MouseMotionAdapter
from com.jidesoft.grid import TableModelWrapperUtils
from java.awt import Cursor
		
class CellMotionListener(MouseMotionAdapter):
	def __init__ (self, colNames, cursor):
		MouseMotionAdapter. __init__ (self)
		
		self.colNames = colNames if isinstance(colNames, (tuple, list)) else []
        self.ccursor = cursor
	
	def mouseMoved(self, e):
		arow = TableModelWrapperUtils.getActualRowAt(e.source.model, e.source.rowAtPoint(e.point))
		acol = TableModelWrapperUtils.getActualColumnAt(e.source.model, e.source.columnAtPoint(e.point))
		
		#Traverse back to the VisionAdvancedTable component
		vat = e.source.parent.parent
		
		#Use the helper method to get the actual column index in the "data" attribute
		colName = vat.data.getColumnName(vat.columnIndexToDatasetIndex(acol))
		
		if colName in self.colNames and vat.data.getValueAt(arow, colName) is not None:
			if e.source.cursor.type != self.ccursor:
				e.source.cursor = Cursor.getPredefinedCursor(self.ccursor)
		else:
			if e.source.cursor.type != Cursor.DEFAULT_CURSOR:
				e.source.cursor = Cursor.getDefaultCursor()

```

Then, in the “Initialize” Extension Function on my Power Table, I put this code. In my case, I want the “hand” icon to appear when the user mouses over a column named “email” in the underlying dataset, to indicate that it’s a “link” that could be clicked on. I used the literal form of a single-element tuple (since I only care about one column), but you could potentially have more columns that you might want the “hand” cursor for. You could also specify a different cursor type here as well.

```auto
from java.awt import Cursor

table = self.getTable() 
table.addMouseMotionListener(Utils.CellMotionListener(('email',), Cursor.HAND_CURSOR))

```

It feels a bit clunky to be setting the cursor for the _entire_ table, but it seems to perform well.

---

<div class="post-metadata">

**Author:** ![n099y](https://avatars.discourse-cdn.com/v4/letter/n/258eb7/32.png) [@n099y](https://forum.inductiveautomation.com/u/n099y)\
**Post date:** [August 19, 2026, 9:51pm UTC](https://forum.inductiveautomation.com/t/mouse-cursor-point-to-hand-change-over-specific-cell/46851/12 "2026-08-19T21:51:29Z")

</div>

I could not get any of these to work but I found this worked well. Just in case future people need.

```python
def initialize(self):

	from java.awt import Cursor
	from java.awt.event import MouseMotionAdapter
	
	# Capture a direct reference to the Power Table component and its raw data
	power_table = self
	
	class HoverCursorListener(MouseMotionAdapter):
	    def __init__ (self, table_view):
	        self.view = table_view # This is the internal JTable UI view
	
	    def mouseMoved(self, event):
	        point = event.getPoint()
	        row = self.view.rowAtPoint(point)
	        view_col = self.view.columnAtPoint(point)
	        
	        if row != -1 and view_col != -1:
	            # 1. Map the visual column index to the view's model index
	            model_col = self.view.convertColumnIndexToModel(view_col)
	            
	            # 2. Safely grab the original dataset column name from the Power Table scope
	            col_name = power_table.data.getColumnName(model_col)
	            
	            # Check against the raw dataset name (ignores Alt+255 layout string)
	            if col_name == "save_row":
	                self.view.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR))
	                return
	                
	            is_editable = self.view.isCellEditable(row, view_col)
	            if is_editable:
	                self.view.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR))
	                return
	                
	        self.view.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR))
	
	# Get the UI view and attach the listener
	table_view = self.getTable()
	table_view.addMouseMotionListener(HoverCursorListener(table_view))

```
