From dbacf096c6d71b34a36492ce8f3d048019141561 Mon Sep 17 00:00:00 2001 From: Glavo Date: Wed, 4 Feb 2026 21:56:41 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20#5431:=20=E4=BF=AE=E5=A4=8D=E9=83=A8?= =?UTF-8?q?=E5=88=86=E9=A1=B5=E9=9D=A2=E5=BC=B9=E5=87=BA=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E4=BC=9A=E8=A2=AB=E9=87=8D=E5=A4=8D=E8=A7=A6=E5=8F=91=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#5432)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/jfoenix/controls/JFXPopup.java | 15 +++++++++++---- .../hmcl/ui/construct/LineSelectButton.java | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/HMCL/src/main/java/com/jfoenix/controls/JFXPopup.java b/HMCL/src/main/java/com/jfoenix/controls/JFXPopup.java index 89e9900d2..659c252ff 100644 --- a/HMCL/src/main/java/com/jfoenix/controls/JFXPopup.java +++ b/HMCL/src/main/java/com/jfoenix/controls/JFXPopup.java @@ -127,6 +127,10 @@ public class JFXPopup extends PopupControl { /// @param initOffsetX on the x-axis /// @param initOffsetY on the y-axis public void show(Node node, PopupVPosition vAlign, PopupHPosition hAlign, double initOffsetX, double initOffsetY) { + show(node, vAlign, hAlign, initOffsetX, initOffsetY, false); + } + + public void show(Node node, PopupVPosition vAlign, PopupHPosition hAlign, double initOffsetX, double initOffsetY, boolean attachToNode) { if (!isShowing()) { Scene scene = node.getScene(); if (scene == null || scene.getWindow() == null) { @@ -137,10 +141,13 @@ public class JFXPopup extends PopupControl { boolean isRTL = node.getEffectiveNodeOrientation() == NodeOrientation.RIGHT_TO_LEFT; - this.show(node, - parent.getX() + scene.getX() + origin.getX() + (hAlign == PopupHPosition.RIGHT ? ((Region) node).getWidth() : 0), - parent.getY() + origin.getY() + scene.getY() + (vAlign == PopupVPosition.BOTTOM ? ((Region) node).getHeight() : 0) - ); + double anchorX = parent.getX() + scene.getX() + origin.getX() + (hAlign == PopupHPosition.RIGHT ? ((Region) node).getWidth() : 0); + double anchorY = parent.getY() + origin.getY() + scene.getY() + (vAlign == PopupVPosition.BOTTOM ? ((Region) node).getHeight() : 0); + + if (attachToNode) + this.show(node, anchorX, anchorY); + else + this.show(parent, anchorX, anchorY); ((JFXPopupSkin) getSkin()).reset(vAlign, isRTL ? hAlign.getOpposite() : hAlign, isRTL ? -initOffsetX : initOffsetX, initOffsetY); Platform.runLater(() -> ((JFXPopupSkin) getSkin()).animate()); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/LineSelectButton.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/LineSelectButton.java index 2938b2167..4bbf5f1d5 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/LineSelectButton.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/LineSelectButton.java @@ -137,7 +137,8 @@ public final class LineSelectButton extends LineButton { JFXPopup.PopupVPosition vPosition = determineOptimalPopupPosition(this, popup); popup.show(this, vPosition, JFXPopup.PopupHPosition.RIGHT, 0, - vPosition == JFXPopup.PopupVPosition.TOP ? this.getHeight() : -this.getHeight()); + vPosition == JFXPopup.PopupVPosition.TOP ? this.getHeight() : -this.getHeight(), + true); } }