Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » A way to disable the default popup menu (right clicking on editable cell)?
A way to disable the default popup menu (right clicking on editable cell)? [message #1758638] Thu, 30 March 2017 22:05 Go to next message
Maximus X is currently offline Maximus XFriend
Messages: 6
Registered: March 2017
Junior Member
Is there a way to disable the default popup menu which comes up when an editable cell is first selected, bringing it to edit mode, and then right clicked?

Ideally I would like to disable it only for a few specific columns (where my own MenuConfiguration class would take over instead)... what would be the best way to approach this problem?


index.php/fa/28934/0/
Re: A way to disable the default popup menu (right clicking on editable cell)? [message #1758649 is a reply to message #1758638] Fri, 31 March 2017 07:28 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2624
Registered: July 2012
Senior Member
The popup menu you see is the native menu of the SWT Text control. To get rid of it you need a customized TextCellEditor where you customize the created Text control.

To disable the context menu completely you could do this like this:

configRegistry.registerConfigAttribute(
        EditConfigAttributes.CELL_EDITOR,
        new TextCellEditor() {
            @Override
            public Text createEditorControl(Composite parent) {
                Text textControl = super.createEditorControl(parent);
                // disable context menu in Text field
                textControl.addMenuDetectListener(new MenuDetectListener() {
                    @Override
                    public void menuDetected(MenuDetectEvent e) {
                        e.doit = false;
                    }
                });
                return textControl;
            }
        },
        DisplayMode.NORMAL,
        ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + "0");


To attach a custom Menu it would look like this:

configRegistry.registerConfigAttribute(
        EditConfigAttributes.CELL_EDITOR,
        new TextCellEditor(true, true) {
            @Override
            public Text createEditorControl(Composite parent) {
                Text textControl = super.createEditorControl(parent);
                Menu menu = new Menu(textControl);
                MenuItem item = new MenuItem(menu, SWT.PUSH);
                item.setText("Custom item");
                textControl.setMenu(menu);
                return textControl;
            }
        },
        DisplayMode.NORMAL,
        ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + "0");


To use the menu you registered the NatTable way, you would need to connect your configuration with your MenuConfiguration and get the SWT Menu from there.
Re: A way to disable the default popup menu (right clicking on editable cell)? [message #1775663 is a reply to message #1758649] Thu, 02 November 2017 23:23 Go to previous messageGo to next message
Louis Detweiler is currently offline Louis DetweilerFriend
Messages: 57
Registered: August 2017
Member
Is it possible to do something similar for a ComboBoxCellEditor? I tried something similar but it didn't work.

    ComboBoxCellEditor parentComboBoxCellEditor =
        new ComboBoxCellEditor(requirementsTable.getRequirement()) {
      @Override
      public NatCombo createEditorControl(Composite parent) {
          NatCombo control = super.createEditorControl(parent);
          control.setMenu(menuConfiguration.buildRowHeaderMenu());
          return control;
      }
    };
Re: A way to disable the default popup menu (right clicking on editable cell)? [message #1775671 is a reply to message #1775663] Fri, 03 November 2017 04:36 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2624
Registered: July 2012
Senior Member
Probably not as NatCombo#setMenu() is not overriden. Would be a new feature request for NatCombo. Feel free to create a ticket and provide a patch.
Previous Topic:Text wrapping in row header region and cells in edit mode
Next Topic:Some strange behavior with multiselect checkbox combobox dropdown
Goto Forum:
  


Current Time: Thu Nov 15 12:31:52 GMT 2018

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

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

Back to the top