From 7bfb1e0f01100d7e446e41c00f478f5d7433cb6c Mon Sep 17 00:00:00 2001 From: weisj Date: Sun, 15 Mar 2020 13:01:07 +0100 Subject: [PATCH] Added option to toggle `CheckBoxMenuItem.doNotCloseOnMouseClick` and `RadioButtonMenuItem.doNotCloseOnMouseClick`. --- .../weisj/darklaf/ui/checkbox/DarkCheckBoxMenuItemUI.java | 4 +++- .../darklaf/ui/radiobutton/DarkRadioButtonMenuItemUI.java | 4 +++- .../github/weisj/darklaf/properties/ui/menuItem.properties | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/checkbox/DarkCheckBoxMenuItemUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/checkbox/DarkCheckBoxMenuItemUI.java index 70f9f0e5..673a76a7 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/checkbox/DarkCheckBoxMenuItemUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/checkbox/DarkCheckBoxMenuItemUI.java @@ -39,6 +39,8 @@ import java.awt.*; */ public class DarkCheckBoxMenuItemUI extends DarkMenuItemUIBase { + public static final String KEY_PREFIX = "CheckBoxMenuItem"; + public static final String KEY_NO_NOT_CLOSE_ON_CLICK = KEY_PREFIX + ".doNotCloseOnMouseClick"; private final MouseClickListener clickListener = e -> SwingUtilities.invokeLater(() -> { if (menuItem != null) menuItem.setArmed(true); }); @@ -58,7 +60,7 @@ public class DarkCheckBoxMenuItemUI extends DarkMenuItemUIBase { @Override public void installUI(final JComponent c) { super.installUI(c); - c.putClientProperty("CheckBoxMenuItem.doNotCloseOnMouseClick", Boolean.TRUE); + c.putClientProperty(KEY_NO_NOT_CLOSE_ON_CLICK, UIManager.getBoolean(KEY_NO_NOT_CLOSE_ON_CLICK)); } protected void paintCheckIcon(final Graphics g2, final MenuItemLayoutHelper lh, diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/radiobutton/DarkRadioButtonMenuItemUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/radiobutton/DarkRadioButtonMenuItemUI.java index a4b96328..30c55871 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/radiobutton/DarkRadioButtonMenuItemUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/radiobutton/DarkRadioButtonMenuItemUI.java @@ -36,6 +36,8 @@ import java.awt.*; */ public class DarkRadioButtonMenuItemUI extends DarkMenuItemUIBase { + public static final String KEY_PREFIX = "RadioButtonMenuItem"; + public static final String KEY_NO_NOT_CLOSE_ON_CLICK = KEY_PREFIX + ".doNotCloseOnMouseClick"; private final MouseClickListener clickListener = e -> SwingUtilities.invokeLater(() -> { if (menuItem != null) menuItem.setArmed(true); }); @@ -58,7 +60,7 @@ public class DarkRadioButtonMenuItemUI extends DarkMenuItemUIBase { acceleratorFont = UIManager.getFont("MenuItem.font"); acceleratorForeground = UIManager.getColor("MenuItem.foreground"); acceleratorSelectionForeground = UIManager.getColor("MenuItem.selectionForeground"); - c.putClientProperty("RadioButtonMenuItem.doNotCloseOnMouseClick", Boolean.TRUE); + c.putClientProperty(KEY_NO_NOT_CLOSE_ON_CLICK, UIManager.getBoolean(KEY_NO_NOT_CLOSE_ON_CLICK)); } @Override diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuItem.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuItem.properties index 00006427..88866a7b 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuItem.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuItem.properties @@ -36,6 +36,7 @@ RadioButtonMenuItem.borderPainted = false RadioButtonMenuItem.acceleratorForeground = %acceleratorForeground RadioButtonMenuItem.acceleratorSelectionForeground = %acceleratorForeground RadioButtonMenuItem.selectionBackground = %highlightFillFocus +RadioButtonMenuItem.doNotCloseOnMouseClick = true CheckBoxMenuItemUI = com.github.weisj.darklaf.ui.checkbox.DarkCheckBoxMenuItemUI CheckBoxMenuItem.borderPainted = false @@ -43,10 +44,11 @@ CheckBoxMenuItem.acceleratorForeground = %acceleratorForeground CheckBoxMenuItem.acceleratorSelectionForeground = %acceleratorForeground CheckBoxMenuItem.selectionBackground = %highlightFillFocus CheckBoxMenuItem.foreground = %textForeground +CheckBoxMenuItem.doNotCloseOnMouseClick = true #Icons MenuItem.arrowIcon = navigation/arrowRight.svg[themed] MenuItem.arrowHover.icon = navigation/arrowRightHover.svg[themed] RadioButtonMenuItem.arrowIcon = empty(16,16) CheckBoxMenuItem.checkIcon = empty(19,19) -RadioButtonMenuItem.checkIcon = empty(19,19) \ No newline at end of file +RadioButtonMenuItem.checkIcon = empty(19,19)