# Catching click and right-click events on power table headers

**URL:** <https://forum.inductiveautomation.com/t/catching-click-and-right-click-events-on-power-table-headers/14842>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [July 20, 2017, 1:30pm UTC](https://forum.inductiveautomation.com/t/catching-click-and-right-click-events-on-power-table-headers/14842 "2017-07-20T13:30:41Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [July 25, 2017, 11:38am UTC](https://forum.inductiveautomation.com/t/catching-click-and-right-click-events-on-power-table-headers/14842/3 "2017-07-25T11:38:41Z")

</div>

I ended up putting this code in the “Initialise” function of the powertable:

```auto
	# put your initialization code here
	from java.awt.event import MouseAdapter
	import com.jidesoft.grid
	
	class TableHeaderMouseListener(MouseAdapter):
		def __init__ (self,table):
			self.table = table
			
		def mouseClicked(self,e):
			self.table.headerClickHandler(e, "CLICKED")
			
		def mouseReleased(self, e):
			self.table.headerClickHandler(e, "RELEASED")
	
	table = self
	header = table.getTable().getTableHeader()
	
	# Remove any existing mouse listeners. 
	mls = header.getMouseListeners()
	for m in mls:
		if type(m) == com.jidesoft.grid.TableHeaderPopupMenuInstaller:
			header.removeMouseListener(m)
	header.addMouseListener(TableHeaderMouseListener(table))

```

This code only removes the popup menu listener, while it keeps other listeners (like the column resize listener). Then the code actually handling the clicks is defined in an separate function. The initialise function is only handled when the table is loaded for the first time, but that doesn’t matter here, as the bulk of code is defined in a different function which is reloaded on every call.

---

_[View the full topic](https://forum.inductiveautomation.com/t/catching-click-and-right-click-events-on-power-table-headers/14842)._
