# How do you unselect a Power Table row without using CTRL key

**URL:** <https://forum.inductiveautomation.com/t/how-do-you-unselect-a-power-table-row-without-using-ctrl-key/36722>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [July 15, 2020, 12:35pm UTC](https://forum.inductiveautomation.com/t/how-do-you-unselect-a-power-table-row-without-using-ctrl-key/36722 "2020-07-15T12:35:38Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [July 15, 2020, 12:35pm UTC](https://forum.inductiveautomation.com/t/how-do-you-unselect-a-power-table-row-without-using-ctrl-key/36722/1 "2020-07-15T12:35:38Z")

</div>

Good morning,

I want to be able to select a power table row with a mouse click and then also unselect the power table row with a mouse click. (Typically you unselect a row using CTRL + mouse click on a row.) The reason for this is the user has a touchscreen and wont be able to access a CTRL key.

Thanks for any help.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [July 15, 2020, 12:46pm UTC](https://forum.inductiveautomation.com/t/how-do-you-unselect-a-power-table-row-without-using-ctrl-key/36722/2 "2020-07-15T12:46:54Z")

</div>

The link has some information on table selection Java methods  
[https://docs.oracle.com/javase/7/docs/api/javax/swing/JTable.html#setRowSelectionInterval(int,%20int)](https://docs.oracle.com/javase/7/docs/api/javax/swing/JTable.html#setRowSelectionInterval(int,%20int))  
Your script should look something like this

```auto
target = event.source.parent.getComponent('Power Table').getTable()
selection = target.getSelectedRow()
if selection != -1:
    target.clearSelection()

```

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [July 15, 2020, 12:47pm UTC](https://forum.inductiveautomation.com/t/how-do-you-unselect-a-power-table-row-without-using-ctrl-key/36722/3 "2020-07-15T12:47:24Z")

</div>

I was able to do this by adding a custom properrty to a power table named selectedRowPrevious and then using the following script in the table’s onMousePress event.

I assume this will work on a touch screen.

```auto
	if self.selectedRowPrevious == rowIndex:
		self.selectedRow = -1
	self.selectedRowPrevious = rowIndex

```

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [July 15, 2020, 1:12pm UTC](https://forum.inductiveautomation.com/t/how-do-you-unselect-a-power-table-row-without-using-ctrl-key/36722/4 "2020-07-15T13:12:27Z")

</div>

Thank you both. Both solutions work but JGJohnson’s solution works better for my particular application.

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [July 15, 2020, 1:15pm UTC](https://forum.inductiveautomation.com/t/how-do-you-unselect-a-power-table-row-without-using-ctrl-key/36722/5 "2020-07-15T13:15:07Z")

</div>

> [@JGJohnson](#):
>
> I assume this will work on a touch screen.

IIRC, I think this depends on the touchscreen and its driver. Some touchscreens will emulate a mouse click where some will not.

---

<div class="post-metadata">

**Author:** ![user62](https://avatars.discourse-cdn.com/v4/letter/u/e47774/32.png) [@user62](https://forum.inductiveautomation.com/u/user62)\
**Post date:** [November 16, 2021, 5:20pm UTC](https://forum.inductiveautomation.com/t/how-do-you-unselect-a-power-table-row-without-using-ctrl-key/36722/6 "2021-11-16T17:20:41Z")

</div>

JGJohnson  
what is your property selectedRowPrevious binded to? I’m trying to understand the code and maybe use it here. Thanks

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [November 16, 2021, 7:25pm UTC](https://forum.inductiveautomation.com/t/how-do-you-unselect-a-power-table-row-without-using-ctrl-key/36722/7 "2021-11-16T19:25:32Z")

</div>

It’s not bound to anything. It’s just a custom property I added to the table that gets updated whenever a row is clicked (The 3rd row in my script handles this).

---

<div class="post-metadata">

**Author:** ![user62](https://avatars.discourse-cdn.com/v4/letter/u/e47774/32.png) [@user62](https://forum.inductiveautomation.com/u/user62)\
**Post date:** [November 16, 2021, 7:39pm UTC](https://forum.inductiveautomation.com/t/how-do-you-unselect-a-power-table-row-without-using-ctrl-key/36722/8 "2021-11-16T19:39:28Z")

</div>

Interesting, I will do so and see how it goes. I’ve been fighting to have a single left click select and deselected rows that is beyond the first selected row, for an easier touch screen experience. Thank you for your help my friend.

Forgot to mention: Without using the CTRL Key 😃 I like to make it spicy, lol.

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [November 16, 2021, 9:17pm UTC](https://forum.inductiveautomation.com/t/how-do-you-unselect-a-power-table-row-without-using-ctrl-key/36722/9 "2021-11-16T21:17:47Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/9/9977a7c5f01219fc4e57de42af1d5516ebbefd43.png)

Modified code so you can select/unselect the same row multiple times.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [October 16, 2025, 4:14pm UTC](https://forum.inductiveautomation.com/t/how-do-you-unselect-a-power-table-row-without-using-ctrl-key/36722/10 "2025-10-16T16:14:53Z")

</div>

This works unless the user tries to re-select the row they just unselected.

This script works:

```python
if self.lastRow == rowIndex:
		self.selectedRow = -1
		self.selectedColumn = -1
		self.lastRow = -1
	else:
		self.lastRow = rowIndex

```
