Search code examples
javaswtjfacekeylistenertableviewer

Add listener to TableViewer editing column


Is it possible to add a listener to the column where editing is enabled?

I enabled editing support and would like to add a keylistener to be able to track live changes but I can't find anything


Solution

  • If your EditingSupport class is using the TextCellEditor you can replace that with a class extending TextCellEditor to gain access to the Text control and various predefined methods.

    The Text control in TextCellEditor is stored in a field called text which you can access from your sub-class.

    TextCellEditor already has a key listener and defines a:

    protected void keyReleaseOccured(KeyEvent keyEvent)
    

    method that you can override. Be sure to call super.keyReleaseOccured(keyEvent) if you override this as there is important code in this method.