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) {