2828import javafx .collections .ObservableList ;
2929import javafx .css .PseudoClass ;
3030import javafx .geometry .Pos ;
31+ import javafx .scene .Node ;
3132import javafx .scene .control .Label ;
3233import javafx .scene .input .*;
3334import javafx .scene .layout .StackPane ;
3738import org .jackhuang .hmcl .util .javafx .MappedObservableList ;
3839
3940import java .util .Collection ;
41+ import java .util .List ;
4042import java .util .Objects ;
4143import java .util .function .Function ;
4244
@@ -49,6 +51,8 @@ public class LineSelectButton<T> extends LineButton {
4951 private static final PseudoClass SELECTED_PSEUDO_CLASS = PseudoClass .getPseudoClass ("selected" );
5052
5153 private JFXPopup popup ;
54+ @ SuppressWarnings ({"FieldCanBeLocal" , "unused" })
55+ private ObservableList <Node > popupItems ; // keep a reference
5256
5357 public LineSelectButton () {
5458 this .getStyleClass ().add (DEFAULT_STYLE_CLASS );
@@ -87,7 +91,7 @@ public void fire() {
8791
8892 ripplerContainer .addEventFilter (ScrollEvent .ANY , ignored -> popup .hide ());
8993
90- Bindings .bindContent (popupMenu .getContent (), MappedObservableList .create (itemsProperty (), item -> {
94+ Bindings .bindContent (popupMenu .getContent (), popupItems = MappedObservableList .create (itemsProperty (), item -> {
9195 VBox vbox = new VBox ();
9296
9397 var itemTitleLabel = new Label ();
0 commit comments