Skip to content

Commit 35317ff

Browse files
update
1 parent 607a119 commit 35317ff

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/BuiltInModListPageSkin.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ private class JijModListCell extends MDListCell<ModListPageSkin.ModInfoObject> {
181181

182182
private final ImageView imageView = new ImageView();
183183
private final TwoLineListItem content = new TwoLineListItem();
184+
private JFXPopup activePopup;
185+
private boolean ignoreNextClick = false;
184186

185187
public JijModListCell(JFXListView<ModListPageSkin.ModInfoObject> listView) {
186188
super(listView);
@@ -203,11 +205,32 @@ public JijModListCell(JFXListView<ModListPageSkin.ModInfoObject> listView) {
203205

204206
setSelectable();
205207

208+
this.setOnMousePressed(e -> {
209+
if (activePopup != null && activePopup.isShowing()) {
210+
ignoreNextClick = true;
211+
} else {
212+
ignoreNextClick = false;
213+
}
214+
});
215+
206216
this.setOnMouseClicked(e -> {
207217
if (getItem() != null && getItem().getModInfo() != null) {
208218
LocalModFile modFile = getItem().getModInfo();
209219
if (modFile.hasBundledMods()) {
210-
showBundledPopup(this, modFile.getName(), modFile.getBundledMods());
220+
221+
if (activePopup != null && activePopup.isShowing()) {
222+
activePopup.hide();
223+
activePopup = null;
224+
return;
225+
}
226+
227+
activePopup = showBundledPopup(this, modFile.getName(), modFile.getBundledMods());
228+
229+
activePopup.setOnHidden(event -> {
230+
if (activePopup == event.getSource()) {
231+
activePopup = null;
232+
}
233+
});
211234
}
212235
}
213236
});
@@ -259,7 +282,7 @@ protected void updateControl(ModListPageSkin.ModInfoObject dataItem, boolean emp
259282
}
260283
}
261284

262-
private void showBundledPopup(Node anchor, String modName, List<String> bundledMods) {
285+
private JFXPopup showBundledPopup(Node anchor, String modName, List<String> bundledMods) {
263286
VBox root = new VBox(10);
264287
root.setPadding(new Insets(15));
265288
root.setMaxHeight(400);
@@ -333,6 +356,7 @@ private void showBundledPopup(Node anchor, String modName, List<String> bundledM
333356

334357
JFXPopup popup = new JFXPopup(root);
335358
popup.show(anchor, JFXPopup.PopupVPosition.TOP, JFXPopup.PopupHPosition.RIGHT, 0, anchor.getLayoutBounds().getHeight() + 5);
359+
return popup;
336360
}
337361

338362
private static void exportJijList(String modName, List<String> bundledMods) {

0 commit comments

Comments
 (0)