Stop NatTable from going into edit mode when an editable cell is left-mouse-clicked

让人想犯罪 __ 提交于 2021-02-10 14:49:02

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!