Browse Source

Added option to toggle `CheckBoxMenuItem.doNotCloseOnMouseClick` and `RadioButtonMenuItem.doNotCloseOnMouseClick`.

pull/77/head
weisj 5 years ago
parent
commit
7bfb1e0f01
  1. 4
      core/src/main/java/com/github/weisj/darklaf/ui/checkbox/DarkCheckBoxMenuItemUI.java
  2. 4
      core/src/main/java/com/github/weisj/darklaf/ui/radiobutton/DarkRadioButtonMenuItemUI.java
  3. 2
      core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuItem.properties

4
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 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(() -> { private final MouseClickListener clickListener = e -> SwingUtilities.invokeLater(() -> {
if (menuItem != null) menuItem.setArmed(true); if (menuItem != null) menuItem.setArmed(true);
}); });
@ -58,7 +60,7 @@ public class DarkCheckBoxMenuItemUI extends DarkMenuItemUIBase {
@Override @Override
public void installUI(final JComponent c) { public void installUI(final JComponent c) {
super.installUI(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, protected void paintCheckIcon(final Graphics g2, final MenuItemLayoutHelper lh,

4
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 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(() -> { private final MouseClickListener clickListener = e -> SwingUtilities.invokeLater(() -> {
if (menuItem != null) menuItem.setArmed(true); if (menuItem != null) menuItem.setArmed(true);
}); });
@ -58,7 +60,7 @@ public class DarkRadioButtonMenuItemUI extends DarkMenuItemUIBase {
acceleratorFont = UIManager.getFont("MenuItem.font"); acceleratorFont = UIManager.getFont("MenuItem.font");
acceleratorForeground = UIManager.getColor("MenuItem.foreground"); acceleratorForeground = UIManager.getColor("MenuItem.foreground");
acceleratorSelectionForeground = UIManager.getColor("MenuItem.selectionForeground"); 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 @Override

2
core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuItem.properties

@ -36,6 +36,7 @@ RadioButtonMenuItem.borderPainted = false
RadioButtonMenuItem.acceleratorForeground = %acceleratorForeground RadioButtonMenuItem.acceleratorForeground = %acceleratorForeground
RadioButtonMenuItem.acceleratorSelectionForeground = %acceleratorForeground RadioButtonMenuItem.acceleratorSelectionForeground = %acceleratorForeground
RadioButtonMenuItem.selectionBackground = %highlightFillFocus RadioButtonMenuItem.selectionBackground = %highlightFillFocus
RadioButtonMenuItem.doNotCloseOnMouseClick = true
CheckBoxMenuItemUI = com.github.weisj.darklaf.ui.checkbox.DarkCheckBoxMenuItemUI CheckBoxMenuItemUI = com.github.weisj.darklaf.ui.checkbox.DarkCheckBoxMenuItemUI
CheckBoxMenuItem.borderPainted = false CheckBoxMenuItem.borderPainted = false
@ -43,6 +44,7 @@ CheckBoxMenuItem.acceleratorForeground = %acceleratorForeground
CheckBoxMenuItem.acceleratorSelectionForeground = %acceleratorForeground CheckBoxMenuItem.acceleratorSelectionForeground = %acceleratorForeground
CheckBoxMenuItem.selectionBackground = %highlightFillFocus CheckBoxMenuItem.selectionBackground = %highlightFillFocus
CheckBoxMenuItem.foreground = %textForeground CheckBoxMenuItem.foreground = %textForeground
CheckBoxMenuItem.doNotCloseOnMouseClick = true
#Icons #Icons
MenuItem.arrowIcon = navigation/arrowRight.svg[themed] MenuItem.arrowIcon = navigation/arrowRight.svg[themed]

Loading…
Cancel
Save