From a53bfed0600d9bcb2e471aaf7d5f72842b0b8a43 Mon Sep 17 00:00:00 2001 From: huanghongxun Date: Mon, 19 Aug 2019 00:38:31 +0800 Subject: [PATCH] Add primary and secondary click action on GameListItem --- .../hmcl/ui/versions/GameListItemSkin.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameListItemSkin.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameListItemSkin.java index c9eaa71b5..c6364e21e 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameListItemSkin.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameListItemSkin.java @@ -22,7 +22,9 @@ import com.jfoenix.controls.JFXPopup; import com.jfoenix.controls.JFXRadioButton; import com.jfoenix.effects.JFXDepthManager; import javafx.geometry.Pos; +import javafx.scene.Cursor; import javafx.scene.control.SkinBase; +import javafx.scene.input.MouseButton; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import org.jackhuang.hmcl.setting.Theme; @@ -49,7 +51,9 @@ public class GameListItemSkin extends SkinBase { chkSelected.setToggleGroup(skinnable.getToggleGroup()); root.setLeft(chkSelected); - root.setCenter(new GameItem(skinnable.getProfile(), skinnable.getVersion())); + GameItem gameItem = new GameItem(skinnable.getProfile(), skinnable.getVersion()); + gameItem.setMouseTransparent(true); + root.setCenter(gameItem); PopupMenu menu = new PopupMenu(); JFXPopup popup = new JFXPopup(menu); @@ -91,5 +95,16 @@ public class GameListItemSkin extends SkinBase { JFXDepthManager.setDepth(root, 1); getChildren().setAll(root); + + root.setCursor(Cursor.HAND); + root.setOnMouseClicked(e -> { + if (e.getButton() == MouseButton.PRIMARY) { + if (e.getClickCount() == 1) { + skinnable.modifyGameSettings(); + } + } else if (e.getButton() == MouseButton.SECONDARY) { + popup.show(root, JFXPopup.PopupVPosition.TOP, JFXPopup.PopupHPosition.LEFT, e.getX(), e.getY()); + } + }); } }