Search code examples
javaeclipse-rcpjfacecarettablecelleditor

TableViewer how to set caret position for the cell with Editing Support and remove FULL_SELECTION


I have a TableViewer with last column which has EditingSupport to edit the cell's value. The viewer has style set to FULL_SELECTION. Once I click on the cell, the text value is fully selected:

"max value" is fully selected

I can start editing, it will clear off the current value "max value" and start new value.

However, If i want to move the mouse to a specific position to edit, I need to give a delay of a sec or so. If I click too fast right after the first click to select, the cell will be deselected.

Is there any way to avoid that? Can I make the cell not fully selected ? or always have the caret to the end of the text ? Thanks!


Solution

  • I assume you are using TextCellEditor as the cell editor.

    Create your own class extending TextCellEditor and override the doSetFocus class to be something like:

    @Override
    protected void doSetFocus()
    {
      super.doSetFocus();
    
      if (text != null) {
         text.setSelection(0, 0);
       }
    }