支持使用鼠标返回键返回上级 (#3381)

* 支持使用鼠标返回键返回上级

* fix checkstyle
This commit is contained in:
Glavo 2024-10-25 12:36:07 +08:00 committed by GitHub
parent 7645a600ef
commit e051c212d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -30,6 +30,8 @@ import javafx.scene.Node;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.input.DragEvent; import javafx.scene.input.DragEvent;
import javafx.scene.input.KeyEvent; import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*; import javafx.scene.layout.*;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import javafx.stage.Stage; import javafx.stage.Stage;
@ -144,6 +146,18 @@ public class DecoratorController {
// press ESC to go back // press ESC to go back
onEscPressed(navigator, this::back); onEscPressed(navigator, this::back);
try {
// For JavaFX 12+
MouseButton button = MouseButton.valueOf("BACK");
navigator.addEventFilter(MouseEvent.MOUSE_CLICKED, e -> {
if (e.getButton() == button) {
back();
e.consume();
}
});
} catch (IllegalArgumentException ignored) {
}
} }
public Decorator getDecorator() { public Decorator getDecorator() {