From 6124b6711fcd89e845d8955322a397661ff74dfc Mon Sep 17 00:00:00 2001 From: General_K1ng Date: Sat, 31 May 2025 21:48:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E5=88=87=E6=8D=A2=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E6=97=B6=E7=A1=AE=E4=BF=9D=E4=B8=BB=E9=A1=B5=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=88=87=E6=8D=A2=E8=8F=9C=E5=8D=95=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E6=9B=B4=E6=96=B0=20(#3949)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jackhuang/hmcl/ui/main/MainPage.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java index cae033967..05d3b69a9 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java @@ -79,7 +79,9 @@ public final class MainPage extends StackPane implements DecoratorPage { private final ReadOnlyObjectWrapper state = new ReadOnlyObjectWrapper<>(); private final PopupMenu menu = new PopupMenu(); - private final JFXPopup popup = new JFXPopup(menu); + + private final StackPane popupWrapper = new StackPane(menu); + private final JFXPopup popup = new JFXPopup(popupWrapper); private final StringProperty currentGame = new SimpleStringProperty(this, "currentGame"); private final BooleanProperty showUpdate = new SimpleBooleanProperty(this, "showUpdate"); @@ -321,15 +323,27 @@ public final class MainPage extends StackPane implements DecoratorPage { } private void onMenu() { + Node contentNode; if (menu.getContent().isEmpty()) { Label placeholder = new Label(i18n("version.empty")); placeholder.setStyle("-fx-padding: 10px; -fx-text-fill: gray; -fx-font-style: italic;"); - - popup.setPopupContent(placeholder); + contentNode = placeholder; } else { - popup.setPopupContent(menu); + contentNode = menu; } - popup.show(menuButton, JFXPopup.PopupVPosition.BOTTOM, JFXPopup.PopupHPosition.RIGHT, 0, -menuButton.getHeight()); + + popupWrapper.getChildren().setAll(contentNode); + + if (popup.isShowing()) { + popup.hide(); + } + popup.show( + menuButton, + JFXPopup.PopupVPosition.BOTTOM, + JFXPopup.PopupHPosition.RIGHT, + 0, + -menuButton.getHeight() + ); } private void onUpgrade() {