|
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 |
Dirk Fauth Messages: 2902 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.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03137 seconds