问题
NatTable's default behavior when an editable cell is left-mouse-clicked is to immediately launch the cell's editor.
Users sometimes left-click simply to toss focus into the table, and then use the arrow keys to navigate around inside of it. Given the table's default behavior, they first need to dismiss the edit operation via ENTER, ESCAPE, etc. before they can move the cell selection.
I'd like to alter this behavior so that a left-mouse-click selects the cell that was clicked, but does not instigate an edit.
回答1:
The editing triggers are configured in the org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditBindings
class, which is used by org.eclipse.nebula.widgets.nattable.grid.layer.config.DefaultGridLayerConfiguration
.
All you have to do is register a different grid layer configuration which uses a different edit bindings. For example:
GridLayer gridLayer = new GridLayer(bodyLayer, columnHeaderLayer, rowHeaderLayer, cornerLayerStack, false) {
@Override
protected void init(boolean useDefaultConfiguration) {
super.init(useDefaultConfiguration);
addConfiguration(new DefaultGridLayerConfiguration(this) {
@Override
protected void addEditingUIConfig() {
addConfiguration(new DefaultEditBindings() {
@Override
public void configureUiBindings(
UiBindingRegistry uiBindingRegistry) {
super.configureUiBindings(uiBindingRegistry);
//update bindings as you wish
}
});
}
});
}
};
来源:https://stackoverflow.com/questions/31410939/stop-nattable-from-going-into-edit-mode-when-an-editable-cell-is-left-mouse-clic