Skip to content

Commit 6124b67

Browse files
authored
在切换目录时确保主页版本列表切换菜单正确更新 (#3949)
1 parent 3b3cc54 commit 6124b67

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ public final class MainPage extends StackPane implements DecoratorPage {
7979
private final ReadOnlyObjectWrapper<State> state = new ReadOnlyObjectWrapper<>();
8080

8181
private final PopupMenu menu = new PopupMenu();
82-
private final JFXPopup popup = new JFXPopup(menu);
82+
83+
private final StackPane popupWrapper = new StackPane(menu);
84+
private final JFXPopup popup = new JFXPopup(popupWrapper);
8385

8486
private final StringProperty currentGame = new SimpleStringProperty(this, "currentGame");
8587
private final BooleanProperty showUpdate = new SimpleBooleanProperty(this, "showUpdate");
@@ -321,15 +323,27 @@ private void launch() {
321323
}
322324

323325
private void onMenu() {
326+
Node contentNode;
324327
if (menu.getContent().isEmpty()) {
325328
Label placeholder = new Label(i18n("version.empty"));
326329
placeholder.setStyle("-fx-padding: 10px; -fx-text-fill: gray; -fx-font-style: italic;");
327-
328-
popup.setPopupContent(placeholder);
330+
contentNode = placeholder;
329331
} else {
330-
popup.setPopupContent(menu);
332+
contentNode = menu;
333+
}
334+
335+
popupWrapper.getChildren().setAll(contentNode);
336+
337+
if (popup.isShowing()) {
338+
popup.hide();
331339
}
332-
popup.show(menuButton, JFXPopup.PopupVPosition.BOTTOM, JFXPopup.PopupHPosition.RIGHT, 0, -menuButton.getHeight());
340+
popup.show(
341+
menuButton,
342+
JFXPopup.PopupVPosition.BOTTOM,
343+
JFXPopup.PopupHPosition.RIGHT,
344+
0,
345+
-menuButton.getHeight()
346+
);
333347
}
334348

335349
private void onUpgrade() {

0 commit comments

Comments
 (0)