Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Register a normal click in a table with CellEditors(Select a cell with a normal click, CellEditor with the second click)
Register a normal click in a table with CellEditors [message #1770747] Wed, 16 August 2017 17:13 Go to next message
Angel Fraile is currently offline Angel FraileFriend
Messages: 9
Registered: June 2016
Junior Member
Hi! I started a few days ago with NatTables. I am trying to select a CellEditor with a normal mouse click. By default the cellEditor is triggered on leftclick, but I want to trigger the acction with a second click, once the cell is selected.

-First left click: selects a cell
-Second left click on a selected cell: triggers the CellEditor

I tried this:
natTable.addConfiguration(new DefaultEditBindings() {
     public void configureUiBindings(UiBindingRegistry pUiBindingRegistry) {

         pUiBindingRegistry.unregisterSingleClickBinding(new CellEditorMouseEventMatcher(GridRegion.BODY, MouseEventMatcher.LEFT_BUTTON));
         CellEditorMouseEventMatcher mouseEventMatcher = new CellEditorMouseEventMatcher(GridRegion.BODY, MouseEventMatcher.LEFT_BUTTON) {
             public boolean matches(NatTable pNatTable, MouseEvent pEvent, LabelStack pRegionLabels) 
                 return false;       
         pUiBindingRegistry.registerSingleClickBinding(mouseEventMatcher, new MySelectCellAction());

In MySelectCellAction I want to handle the cell selection or the CellEditor action.

When I click in the table the behavior does not change and I am not reach my own function (MySelectCellAction)

Could you please give me some help? Thanks a lot
Re: Register a normal click in a table with CellEditors [message #1770805 is a reply to message #1770747] Thu, 17 August 2017 09:10 Go to previous message
Angel Fraile is currently offline Angel FraileFriend
Messages: 9
Registered: June 2016
Junior Member
Now it is works in this way;

        natTable.addConfiguration(new AbstractUiBindingConfiguration() {
            public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
                uiBindingRegistry.registerFirstSingleClickBinding(new CellEditorMouseEventMatcher(GridRegion.BODY), new MyAction());

    private class MyAction implements IMouseAction {
        public void run(NatTable natTable, MouseEvent event) {
            int cursorCol = natTable.getColumnPositionByX(event.x);
            int cursorRow = natTable.getRowPositionByY(event.y);

            int indexCol = natTable.getColumnIndexByPosition(cursorCol);
            int indexRow = natTable.getRowIndexByPosition(cursorRow);

            boolean isCellSelected = selectionLayer.isCellPositionSelected(indexCol, indexRow);

            if (selectedPreviously) {
                natTable.doCommand(new EditCellCommand(natTable, natTable.getConfigRegistry(), natTable.getCellByPosition(cursorCol, cursorRow)));
            } else {
                natTable.doCommand(new SelectCellCommand(natTable, cursorCol, cursorRow, false, false));

[Updated on: Fri, 18 August 2017 10:38]

Report message to a moderator

Previous Topic:Enable cell decoration outside of editing mode
Next Topic:Can't get TableCellPainter's dynamically calculated sub cell heights to work
Goto Forum:

Current Time: Sun Aug 18 19:21:55 GMT 2019

Powered by FUDForum. Page generated in 0.01659 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top