From ac0a0c76041b31de3b2f5184bde5ef733892d04c Mon Sep 17 00:00:00 2001 From: rootwhois <53112648+rootwhois@users.noreply.github.com> Date: Sat, 20 Sep 2025 16:28:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20AdvancedListBox=20?= =?UTF-8?q?=E5=9C=A8=E9=9D=9E=E5=BF=85=E8=A6=81=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=E6=98=BE=E7=A4=BA=E6=BB=9A=E5=8A=A8=E6=9D=A1=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#4514)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Glavo --- .../org/jackhuang/hmcl/ui/construct/AdvancedListBox.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/AdvancedListBox.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/AdvancedListBox.java index e45e116c9..d47ba4e64 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/AdvancedListBox.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/AdvancedListBox.java @@ -20,6 +20,7 @@ package org.jackhuang.hmcl.ui.construct; import javafx.collections.ObservableList; import javafx.scene.Node; import javafx.scene.control.ScrollPane; +import javafx.scene.input.MouseEvent; import javafx.scene.layout.Pane; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; @@ -40,8 +41,16 @@ public class AdvancedListBox extends ScrollPane { setFitToHeight(true); setFitToWidth(true); setHbarPolicy(ScrollBarPolicy.NEVER); + setVbarPolicy(ScrollBarPolicy.NEVER); container.getStyleClass().add("advanced-list-box-content"); + + this.addEventFilter(MouseEvent.MOUSE_ENTERED, event -> { + if (container.getHeight() > getHeight()) + setVbarPolicy(ScrollBarPolicy.AS_NEEDED); + }); + this.addEventFilter(MouseEvent.MOUSE_EXITED, + event -> setVbarPolicy(ScrollBarPolicy.NEVER)); } public AdvancedListBox add(Node child) {