|
Re: Register a normal click in a table with CellEditors [message #1770805 is a reply to message #1770747] |
Thu, 17 August 2017 09:10 |
Angel Fraile Messages: 10 Registered: June 2016 |
Junior Member |
|
|
Now it is works in this way;
natTable.addConfiguration(new AbstractUiBindingConfiguration() {
@Override
public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
uiBindingRegistry.unregisterMouseDownBinding(MouseEventMatcher.bodyLeftClick(SWT.NONE));
uiBindingRegistry.registerFirstSingleClickBinding(new CellEditorMouseEventMatcher(GridRegion.BODY), new MyAction());
}
});
private class MyAction implements IMouseAction {
@Override
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));
}
natTable.redraw();
}
}
[Updated on: Fri, 18 August 2017 10:38] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.01807 seconds