I ended up putting this code in the “Initialise” function of the powertable:
# 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.