# Power Table Stray Typing

**URL:** <https://forum.inductiveautomation.com/t/power-table-stray-typing/18975>\
**Category:** Ignition\
**Created:** [July 25, 2018, 9:50pm UTC](https://forum.inductiveautomation.com/t/power-table-stray-typing/18975 "2018-07-25T21:50:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![WillMT10](https://avatars.discourse-cdn.com/v4/letter/w/7feea3/32.png) [@WillMT10](https://forum.inductiveautomation.com/u/WillMT10)\
**Post date:** [July 25, 2018, 9:50pm UTC](https://forum.inductiveautomation.com/t/power-table-stray-typing/18975/1 "2018-07-25T21:50:11Z")

</div>

I could be completely missing something simple with the Power Tables. But is there any way to prevent stray typing from being accepted in a Power Table cell? I would like to make it so the user is forced to double click or press Enter on a cell to be able to actually edit it. However, even with the Edit Click Count property set to 2, it will allow stray typing in a cell that doesn’t have focus but is selected/highlighted This can be problematic for us with operators accidentally bumping keys with a cell highlighted.

I’ve tried setting up some custom properties with onDoubleClick and the isCellEditable extension functions, but anything I add ends up requiring a triple click because of the order with which those extension functions trigger.

Hopefully this all makes sense. Any help would be appreciated.

Thanks in advance!  
-Will

Ignition 7.9.6  
Client is MacOSX 10.12.6  
Gateway is Windows 7

---

<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:** [July 25, 2018, 10:21pm UTC](https://forum.inductiveautomation.com/t/power-table-stray-typing/18975/2 "2018-07-25T22:21:46Z")

</div>

Hmm, looks like the ‘edit click count’ field isn’t doing what it’s supposed to. Try this, in `configureEditor`:

```auto
	from javax.swing import DefaultCellEditor, JTextField
	from java.lang import String
	from java.awt.event import MouseEvent
	
	class CustomCellEditor(DefaultCellEditor):
		def isCellEditable(self, event):
			if isinstance(event, MouseEvent):
				return DefaultCellEditor.isCellEditable(self, event) and event.getClickCount() >= 2

	if self.data.getColumnType(colIndex) == String:
		return {'editor': CustomCellEditor(JTextField())}

```

---

<div class="post-metadata">

**Author:** ![WillMT10](https://avatars.discourse-cdn.com/v4/letter/w/7feea3/32.png) [@WillMT10](https://forum.inductiveautomation.com/u/WillMT10)\
**Post date:** [July 25, 2018, 10:35pm UTC](https://forum.inductiveautomation.com/t/power-table-stray-typing/18975/3 "2018-07-25T22:35:37Z")

</div>

That did the trick! Thank you!

Glad to know I wasn’t imagining things. I thought it used to prevent the stray typing when the edit click count was set to two.

Thanks again,  
-Will

---

<div class="post-metadata">

**Author:** ![WillMT10](https://avatars.discourse-cdn.com/v4/letter/w/7feea3/32.png) [@WillMT10](https://forum.inductiveautomation.com/u/WillMT10)\
**Post date:** [July 25, 2018, 11:25pm UTC](https://forum.inductiveautomation.com/t/power-table-stray-typing/18975/4 "2018-07-25T23:25:33Z")

</div>

Along the same lines, any thoughts on the best way to set the focus of a cell when pressing Enter? I have the following code in the “initialize” extension function on my power table to change the behavior of the Enter button press. But I can’t figure out how to actually set the current selected cell to focus owner.

Thanks,  
-Will

```auto
from java.awt.event import KeyEvent
from javax.swing import KeyStroke, JTable, AbstractAction

class EnterPressEvent(AbstractAction):
	def __init__ (self, t):
		self.t = t
		
	def actionPerformed(self, event_trigger):
		print "How do I set focus here?"

self.getTable().getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "Enter_Press_Event_Triggered")
self.getTable().getActionMap().put("Enter_Press_Event_Triggered", EnterPressEvent(self))

```
