[SOLVED] How do you unselect a powertable row without using CTRL key

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.

The link has some information on table selection Java methods
Your script should look something like this

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

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.

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

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

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

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

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

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 :smiley: I like to make it spicy, lol.

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