From e051c212d1a09b37694bcd56f973f8d98fa482d3 Mon Sep 17 00:00:00 2001 From: Glavo Date: Fri, 25 Oct 2024 12:36:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BD=BF=E7=94=A8=E9=BC=A0?= =?UTF-8?q?=E6=A0=87=E8=BF=94=E5=9B=9E=E9=94=AE=E8=BF=94=E5=9B=9E=E4=B8=8A?= =?UTF-8?q?=E7=BA=A7=20(#3381)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 支持使用鼠标返回键返回上级 * fix checkstyle --- .../hmcl/ui/decorator/DecoratorController.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorController.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorController.java index 9b0723999..dc34c42de 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorController.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorController.java @@ -30,6 +30,8 @@ import javafx.scene.Node; import javafx.scene.image.Image; import javafx.scene.input.DragEvent; import javafx.scene.input.KeyEvent; +import javafx.scene.input.MouseButton; +import javafx.scene.input.MouseEvent; import javafx.scene.layout.*; import javafx.scene.paint.Color; import javafx.stage.Stage; @@ -144,6 +146,18 @@ public class DecoratorController { // press ESC to go 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() {