Undo/Redo button, ignore scroll down/up events [message #1793872] |
Fri, 17 August 2018 11:45  |
Eclipse User |
|
|
|
When I run the MinMap example, I notice that the Undo/Redo buttons get active when I scroll down/up. How can this be changed?
The relevant piece of code is:
private Node createButtonBar() {
Button undoButton = new Button("Undo");
undoButton.setDisable(true);
undoButton.setOnAction((e) -> {
try {
domain.getOperationHistory().undo(domain.getUndoContext(), null, null);
} catch (ExecutionException e1) {
e1.printStackTrace();
}
});
Button redoButton = new Button("Redo");
redoButton.setDisable(true);
redoButton.setOnAction((e) -> {
try {
domain.getOperationHistory().redo(domain.getUndoContext(), null, null);
} catch (ExecutionException e1) {
e1.printStackTrace();
}
});
// add listener to the operation history of our domain
// to enable/disable undo/redo buttons as needed
domain.getOperationHistory().addOperationHistoryListener((e) -> {
IUndoContext ctx = domain.getUndoContext();
undoButton.setDisable(!e.getHistory().canUndo(ctx));
redoButton.setDisable(!e.getHistory().canRedo(ctx));
});
return new HBox(10, undoButton, redoButton);
}
I was looking at OperationHistoryEvent.getEventType() method but both all events are returning "5".
[Updated on: Fri, 17 August 2018 11:56] by Moderator
|
|
|
|
|
|
Re: Undo/Redo button, ignore scroll down/up events [message #1803076 is a reply to message #1793965] |
Thu, 21 February 2019 16:02  |
Eclipse User |
|
|
|
Hi Joao,
glad you figured something out!
Another attempt could be to prevent execution of these operations on the domain, so that they will not be added on to the operation history. In order to do that, you would need to exchange the corresponding handlers.
Regarding content changes, you can take a look at CreationPolicy and DeletionPolicy. They are both used in the Logo example.
Best regards and happy coding :-)
Matthias
|
|
|
Powered by
FUDForum. Page generated in 0.03159 seconds