I want to UN-register the NatTable cell editing when typing any "regular" characters such as letters or digits. i.e. On typing any digit or character nothing to be done.
One more question I have registered the TABLE_CYCLE_TRAVERSAL_STRATEGY into my grid layer, work fine with arrow keys and tab as well. But when we press the enter key, the cell selection moving into the next cell.
gridLayer.registerCommandHandler(new MoveCellSelectionCommandHandler(this.selectionLayer,
new EditTraversalStrategy(ITraversalStrategy.TABLE_CYCLE_TRAVERSAL_STRATEGY, this.natTable)));
But I want to implement such a way that, on pressing Enter key, I need to edit a selected cell.
You need to create and register custom configurations.
DefaultEditBindings
You need to remove these two configurations to avoid that the edit mode is activated on key press
uiBindingRegistry.registerKeyBinding(
new LetterOrDigitKeyEventMatcher(),
new KeyEditAction());
uiBindingRegistry.registerKeyBinding(
new LetterOrDigitKeyEventMatcher(SWT.MOD2),
new KeyEditAction());
DefaultSelectionBindings#configureMoveDownBindings()
Remove the following lines to disable the selection movement on ENTER
uiBindingRegistry.registerKeyBinding(
new KeyEventMatcher(SWT.NONE, SWT.CR), action);
uiBindingRegistry.registerKeyBinding(
new KeyEventMatcher(SWT.MOD1, SWT.CR), action);
Register the following UI binding to enable editing on ENTER and SHIFT+ENTER
uiBindingRegistry.registerKeyBinding(
new KeyEventMatcher(SWT.NONE, SWT.CR),
new KeyEditAction());
uiBindingRegistry.registerKeyBinding(
new KeyEventMatcher(SWT.MOD1, SWT.CR),
new KeyEditAction());
Also you need to ensure that the default configurations are not registered by setting the useDefaultConfiguration
constructor parameter to false
. Otherwise the mentioned ui bindings are still registered and triggered (e.g. for the SelectionLayer
you need a customized DefaultSelectionLayerConfiguration
that registers the customized DefaultSelectionBindings
).