|
|
|
|
|
|
Re: Mouse Event handling problem [message #1237743 is a reply to message #1237735] |
Thu, 30 January 2014 08:25   |
Eclipse User |
|
|
|
As you already have your "private" version. Could you please try to add the following code to MouseModeEventHandler and test if it fixes your issue?
And more important, test that it doesn't has impact on existing functionality?
private boolean skipProcessing = false;
@Override
public void mouseUp(final MouseEvent event) {
mouseDown = false;
doubleClick = false;
if (singleClickAction != null) {
//convert/validate/commit/close possible open editor
//needed in case of conversion/validation errors to cancel any action
if (EditUtils.commitAndCloseActiveEditor()) {
if (doubleClickAction != null &&
(isActionExclusive(singleClickAction) || isActionExclusive(doubleClickAction))) {
//If a doubleClick action is registered and either the single click or the double
//click action is exclusive, wait to see if this mouseUp is part of a doubleClick or not.
event.display.timerExec(event.display.getDoubleClickTime(), new Runnable() {
@Override
public void run() {
if (!doubleClick && !skipProcessing) {
executeClickAction(singleClickAction, event);
}
}
});
} else {
executeClickAction(singleClickAction, event);
}
}
}
else if (doubleClickAction == null) {
//No single or double click action registered when mouseUp detected. Switch back to normal mode.
switchMode(Mode.NORMAL_MODE);
}
}
@Override
public void mouseDown(MouseEvent event) {
//another mouse click was performed than initial
//This handling is necessary to react correctly e.g. if an action is registered
//for left double click and an action for right single click. Performing a left
//and right click in short sequence, nothing will happen without this handling
if (event.button != this.initialMouseDownEvent.button) {
//ensure the double click runnable is not executed and process single click immediately
this.skipProcessing = true;
executeClickAction(singleClickAction, event);
//reset to the parent mode
switchMode(Mode.NORMAL_MODE);
//start the mouse event processing for the new button
getModeSupport().mouseDown(event);
}
}
If everything works as intended, I will commit it to core.
Greez,
Dirk
|
|
|
|
|
|
|
Re: Mouse Event handling problem [message #1239083 is a reply to message #1239060] |
Mon, 03 February 2014 05:10   |
Eclipse User |
|
|
|
Both solutions doesn't work for me.
1) move logic from configurable to abstract
the AbstractModeEventHandler doesn't know about the NatTable instance and I don't want to introduce that dependency
2) make mouse extend configurable
also not a good idea, as we would need to ensure that we correctly override every method
Also in case of the MouseModeEventHandler we not only need to execute the key action, we also need to ensure the click handling is executed, e.g. you also have a single click handler that should be executed exclusively, also got a double click handler, and while waiting for the second click, the key action is triggered, which means to execute the single click before the key action, but avoid the double click. Too much dependencies to simply solve it via inheritance.
BTW, as you mentioned key modifiers I noticed that the initial issue would also appear if you click without modifier and soon after clicking again with pressing for example the CTRL key.
And I also noticed that the wrong event is executed for single click execution in mouseDown.
Please try to add this snippet to your codebase and test if it works for and does not have any impact on other use cases.
@Override
public void mouseDown(MouseEvent event) {
//another mouse click was performed than initial
//This handling is necessary to react correctly e.g. if an action is registered
//for left double click and an action for right single click. Performing a left
//and right click in short sequence, nothing will happen without this handling.
//This is also true in case a click is performed without modifier key pressed
//and performing a mouse click with modifier key pressed shortly after.
if ((event.button != this.initialMouseDownEvent.button)
|| (event.stateMask != this.initialMouseDownEvent.stateMask)) {
//ensure the double click runnable is not executed and process single click immediately
this.skipProcessing = true;
executeClickAction(singleClickAction, this.initialMouseDownEvent);
//reset to the parent mode
switchMode(Mode.NORMAL_MODE);
//start the mouse event processing for the new button
getModeSupport().mouseDown(event);
}
}
@Override
public void keyPressed(KeyEvent event) {
//ensure the double click runnable is not executed and process single click immediately
this.skipProcessing = true;
executeClickAction(singleClickAction, this.initialMouseDownEvent);
//reset to the parent mode
switchMode(Mode.NORMAL_MODE);
//start the key event processing
getModeSupport().keyPressed(event);
}
|
|
|
|
|
Re: Mouse Event handling problem [message #1239451 is a reply to message #1239417] |
Tue, 04 February 2014 03:29  |
Eclipse User |
|
|
|
Thanks for testing. I pushed the modification to our repository. Hopefully there are more people involved in testing the current development snapshot so we are able to identify issues with that solution early.
|
|
|
Powered by
FUDForum. Page generated in 0.05096 seconds