Fix #5431: 修复部分页面弹出菜单会被重复触发的问题 (#5432)

This commit is contained in:
Glavo
2026-02-04 21:56:41 +08:00
committed by GitHub
parent c7b9b73292
commit dbacf096c6
2 changed files with 13 additions and 5 deletions

View File

@@ -127,6 +127,10 @@ public class JFXPopup extends PopupControl {
/// @param initOffsetX on the x-axis /// @param initOffsetX on the x-axis
/// @param initOffsetY on the y-axis /// @param initOffsetY on the y-axis
public void show(Node node, PopupVPosition vAlign, PopupHPosition hAlign, double initOffsetX, double initOffsetY) { 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()) { if (!isShowing()) {
Scene scene = node.getScene(); Scene scene = node.getScene();
if (scene == null || scene.getWindow() == null) { if (scene == null || scene.getWindow() == null) {
@@ -137,10 +141,13 @@ public class JFXPopup extends PopupControl {
boolean isRTL = node.getEffectiveNodeOrientation() == NodeOrientation.RIGHT_TO_LEFT; boolean isRTL = node.getEffectiveNodeOrientation() == NodeOrientation.RIGHT_TO_LEFT;
this.show(node, double anchorX = parent.getX() + scene.getX() + origin.getX() + (hAlign == PopupHPosition.RIGHT ? ((Region) node).getWidth() : 0);
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);
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); ((JFXPopupSkin) getSkin()).reset(vAlign, isRTL ? hAlign.getOpposite() : hAlign, isRTL ? -initOffsetX : initOffsetX, initOffsetY);
Platform.runLater(() -> ((JFXPopupSkin) getSkin()).animate()); Platform.runLater(() -> ((JFXPopupSkin) getSkin()).animate());

View File

@@ -137,7 +137,8 @@ public final class LineSelectButton<T> extends LineButton {
JFXPopup.PopupVPosition vPosition = determineOptimalPopupPosition(this, popup); JFXPopup.PopupVPosition vPosition = determineOptimalPopupPosition(this, popup);
popup.show(this, vPosition, JFXPopup.PopupHPosition.RIGHT, popup.show(this, vPosition, JFXPopup.PopupHPosition.RIGHT,
0, 0,
vPosition == JFXPopup.PopupVPosition.TOP ? this.getHeight() : -this.getHeight()); vPosition == JFXPopup.PopupVPosition.TOP ? this.getHeight() : -this.getHeight(),
true);
} }
} }