|
|
|
|
Re: Combo box Editor is not hiding/closing sometimes [message #1732940 is a reply to message #1731692] |
Mon, 23 May 2016 08:51 |
Rashmi Tr Messages: 22 Registered: November 2011 |
Junior Member |
|
|
Hallo Dirk,
The Problem for not hiding/closing of ComboBoxCellEditor was in my case org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditBindings.In this Case, Editor opens with mouse click as well as with mouse move on the cell.
In this one Listener for Single click as well as one Listener for Move is registered. With Move both the Listeners are triggered.
uiBindingRegistry.registerSingleClickBinding(
new CellEditorMouseEventMatcher(GridRegion.BODY),
new MouseEditAction());
uiBindingRegistry.registerMouseDragMode(
new CellEditorMouseEventMatcher(GridRegion.BODY),
new CellEditDragMode());
Both call the Method org.eclipse.nebula.widgets.nattable.edit.EditController.editCell(ILayerCell, Composite, Object, IConfigRegistry), which creates in every call a new editorControl from the same cellEditor.
Both throw in the end a CellEditorCreatedEvent ,which is processed only when both calls are done. In the Event reference of the cellEditor is given, which will be same in both case.
layer.fireLayerEvent(new CellEditorCreatedEvent(cellEditor));
After that the Events from org.eclipse.nebula.widgets.nattable.NatTable.handleLayerEvent(ILayerEvent) will be fired.
if (event instanceof CellEditorCreatedEvent) {
CellEditorCreatedEvent editorEvent = (CellEditorCreatedEvent) event;
this.activeCellEditor = editorEvent.getEditor();
Control editorControl = this.activeCellEditor.getEditorControl();
if (editorControl != null && !editorControl.isDisposed()) {
editorControl.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
NatTable.this.activeCellEditor = null;
ActiveCellEditorRegistry.unregisterActiveCellEditor();
}
});
} else {
this.activeCellEditor = null;
ActiveCellEditorRegistry.unregisterActiveCellEditor();
}
ActiveCellEditorRegistry.registerActiveCellEditor(this.activeCellEditor);
}
Since both are working on the same CellEditor, editorEvent.getEditor() in both case returns the same Instance. But getEditorControl() always returns the last created Editor (i.e NatCombo).
With this the Editor which was created at first is not recognized and thats why it will not be closed.
The Reason for this is Nebula Bugfix for Bug 453882 in the Class org.eclipse.nebula.widgets.nattable.ui.action.DragModeEventHandler.
This throws after Focus Lost one MouseUp Event to remove the created Element after focus lost. Since after mouse click one one Cell and moving on the same cell is not really a Drag & Drop, with move on same cell
a new Element should not be created, this Fix is not necessary for CellEditDragMode.
Actually Mouse Up creates the Editor, so the NatTable lost the Focus und this focus lost calls once again Mouse Up, which creates once again an Editor.
In Example, Editor opens only with mouse click not with mouse move on the cell.Thats why i could not reproduce the error there which i was getting.
Regards,
Rashmi
|
|
|
|
|
|
|
Re: Combo box Editor is not hiding/closing sometimes [message #1763871 is a reply to message #1763868] |
Mon, 22 May 2017 11:19 |
Zachary Labaysse Messages: 5 Registered: March 2015 |
Junior Member |
|
|
Thanks for the quick reply !
First :
I'm using 1.4, I consider upgrading to 1.5 but later, because we're releasing the project to the client next week and I think a such major change should be tested more than one week.
Second :
I have a custom binding configuration, which I think is based on the new way.
I use the DefaultEditBindings.
Third :
I have implemented (10 min ago), I think, a fix for this bug, using what I understood from the Rashmi explanation.
It consists of getting rid of the MouseDragMode in registry. But I cant figure out if it is a wrong way to do it.
I extended the DefaultEditBindings and commented the MouseDragMode lines. is there a better way to do it if it is the good solution ?
public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
// configure the space key to activate a cell editor via keyboard
// this is especially useful for changing the value for a checkbox
uiBindingRegistry.registerKeyBinding(
new KeyEventMatcher(SWT.NONE, 32),
new KeyEditAction());
uiBindingRegistry.registerKeyBinding(
new KeyEventMatcher(SWT.NONE, SWT.F2),
new KeyEditAction());
uiBindingRegistry.registerKeyBinding(
new LetterOrDigitKeyEventMatcher(),
new KeyEditAction());
uiBindingRegistry.registerKeyBinding(
new LetterOrDigitKeyEventMatcher(SWT.MOD2),
new KeyEditAction());
uiBindingRegistry.registerSingleClickBinding(
new CellEditorMouseEventMatcher(GridRegion.BODY),
new MouseEditAction());
// uiBindingRegistry.registerMouseDragMode(
// new CellEditorMouseEventMatcher(GridRegion.BODY),
// new CellEditDragMode());
uiBindingRegistry.registerFirstSingleClickBinding(
new CellPainterMouseEventMatcher(GridRegion.BODY, MouseEventMatcher.LEFT_BUTTON, CheckBoxPainter.class),
new MouseEditAction());
uiBindingRegistry.registerFirstMouseDragMode(
new CellPainterMouseEventMatcher(GridRegion.BODY, MouseEventMatcher.LEFT_BUTTON, CheckBoxPainter.class),
new CellEditDragMode());
}
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05556 seconds