# Power Table onMouseClick using selected cell

**URL:** <https://forum.inductiveautomation.com/t/power-table-onmouseclick-using-selected-cell/70882>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [March 10, 2023, 5:24am UTC](https://forum.inductiveautomation.com/t/power-table-onmouseclick-using-selected-cell/70882 "2023-03-10T05:24:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan\_Kevin\_Dagapioso](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@Dan\_Kevin\_Dagapioso](https://forum.inductiveautomation.com/u/Dan_Kevin_Dagapioso)\
**Post date:** [March 10, 2023, 5:24am UTC](https://forum.inductiveautomation.com/t/power-table-onmouseclick-using-selected-cell/70882/1 "2023-03-10T05:24:29Z")

</div>

I'd like to use onMouseclick function in a power table. The idea is when I click any cell in the power table the green circle in the image will appear. Please help me. Thank you!!

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/2/8295c873221146744d65891b84cdf651a97f160b.png)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [March 10, 2023, 6:10am UTC](https://forum.inductiveautomation.com/t/power-table-onmouseclick-using-selected-cell/70882/2 "2023-03-10T06:10:11Z")

</div>

What is the green circle? Is it a container or some kind of docked window?

---

<div class="post-metadata">

**Author:** ![Dan\_Kevin\_Dagapioso](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@Dan\_Kevin\_Dagapioso](https://forum.inductiveautomation.com/u/Dan_Kevin_Dagapioso)\
**Post date:** [March 10, 2023, 6:11am UTC](https://forum.inductiveautomation.com/t/power-table-onmouseclick-using-selected-cell/70882/3 "2023-03-10T06:11:58Z")

</div>

it is a container

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [March 10, 2023, 6:22am UTC](https://forum.inductiveautomation.com/t/power-table-onmouseclick-using-selected-cell/70882/4 "2023-03-10T06:22:10Z")

</div>

The propertyChange event handler would probably be more appropriate for this. The following script will do what you are wanting:

```auto
if event.propertyName == 'selectedRow' or event.propertyName == 'selectedColumn':
	container = event.source.parent.getComponent('Container') #Change this to the actual path to your container
	selectedRow = event.source.selectedRow
	selectedColumn = event.source.selectedColumn
	if selectedRow == -1 and selectedColumn == -1:
		container.visible = False
	else:
		container.visible = True

```

It simply checks to see which row and column is selected whenever a selection changes. If none are selected, the container looses visibility, but if something is selected, the container regains visibility.

---

<div class="post-metadata">

**Author:** ![Dan\_Kevin\_Dagapioso](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@Dan\_Kevin\_Dagapioso](https://forum.inductiveautomation.com/u/Dan_Kevin_Dagapioso)\
**Post date:** [March 10, 2023, 8:01am UTC](https://forum.inductiveautomation.com/t/power-table-onmouseclick-using-selected-cell/70882/5 "2023-03-10T08:01:20Z")

</div>

just to add the component in the picture can be drag. I just want if the component is hidden because i drag it to the right. when i click the power table cell it will return to its original position. sorry for the insufficient info.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/e/0e5735f7f58feeb9c1979b2c998b763455f5dbe3.png)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [March 10, 2023, 8:20am UTC](https://forum.inductiveautomation.com/t/power-table-onmouseclick-using-selected-cell/70882/6 "2023-03-10T08:20:11Z")

</div>

Is that a Perspective split container? Perhaps we are using the wrong terminology; a power table is a Vision component.

---

<div class="post-metadata">

**Author:** ![Dan\_Kevin\_Dagapioso](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@Dan\_Kevin\_Dagapioso](https://forum.inductiveautomation.com/u/Dan_Kevin_Dagapioso)\
**Post date:** [March 10, 2023, 8:24am UTC](https://forum.inductiveautomation.com/t/power-table-onmouseclick-using-selected-cell/70882/7 "2023-03-10T08:24:23Z")

</div>

it's a vision container. yeah i'm using a power table component.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [March 10, 2023, 9:47am UTC](https://forum.inductiveautomation.com/t/power-table-onmouseclick-using-selected-cell/70882/8 "2023-03-10T09:47:36Z")

</div>

Okay. I believe that I am seeing what you have going on there. If you add the following script to your power table's propertyChange event handler, the side panel will automatically close whenever you select a cell:

```auto
def closeSidePanel():
	seperator = event.source.parent.parent.getComponent('Left Line')
	chartPanel = event.source.parent.parent.getComponent('Easy Chart')
	rightPanel = event.source.parent.parent.getComponent('Pens and Axis')
	totalMovement = rightPanel.width
	system.gui.transform(seperator, (seperator.x + totalMovement), seperator.y, duration = 10)
	system.gui.transform(chartPanel, chartPanel.x, chartPanel.y, (chartPanel.width + totalMovement), duration = 10)
	system.gui.transform(rightPanel, (rightPanel.x + totalMovement), rightPanel.y, (rightPanel.width - totalMovement), duration = 10)
if event.propertyName == 'selectedRow' or event.propertyName == 'selectedColumn':
	selectedRow = event.source.selectedRow
	selectedColumn = event.source.selectedColumn
	if selectedRow != -1 or selectedColumn != -1:
		closeSidePanel()

```

**Edit:** to make this bidirectional, replace `totalMovement = rightPanel.width` with:

```auto
#This will make it open or close depending on the position of the panel
if rightPanel.width > 0:
	totalMovement = rightPanel.width
else:
	quarterOfChartWidth = float(chartPanel.width) * 0.25
	totalMovement = (-1) * int(quarterOfChartWidth)

```
