From 6c875ec0d0b19a552f39b3871dd6eb8e3eb30584 Mon Sep 17 00:00:00 2001 From: Jannis Weis <31143295+weisJ@users.noreply.github.com> Date: Mon, 2 May 2022 21:14:11 +0200 Subject: [PATCH] SplitButton: Respect JComponent#isRequestFocusEnabled --- .../com/github/weisj/darklaf/ui/button/DarkButtonBorder.java | 3 ++- .../darklaf/ui/splitbutton/DarkSplitButtonListener.java | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java index e7ecbc9b..9d1b8950 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java @@ -27,6 +27,8 @@ import javax.swing.border.Border; import javax.swing.plaf.InsetsUIResource; import javax.swing.plaf.UIResource; +import org.jetbrains.annotations.NotNull; + import com.github.weisj.darklaf.graphics.PaintUtil; import com.github.weisj.darklaf.ui.util.DarkUIUtil; import com.github.weisj.darklaf.util.AlignmentExt; @@ -34,7 +36,6 @@ import com.github.weisj.darklaf.util.PropertyUtil; import com.github.weisj.darklaf.util.graphics.GraphicsContext; import com.github.weisj.darklaf.util.graphics.GraphicsUtil; import com.github.weisj.swingdsl.visualpadding.VisualPaddingProvider; -import org.jetbrains.annotations.NotNull; /** @author Jannis Weis */ public class DarkButtonBorder implements Border, UIResource, VisualPaddingProvider { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/splitbutton/DarkSplitButtonListener.java b/core/src/main/java/com/github/weisj/darklaf/ui/splitbutton/DarkSplitButtonListener.java index 2df2d9d5..7df1d947 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/splitbutton/DarkSplitButtonListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/splitbutton/DarkSplitButtonListener.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2019-2021 Jannis Weis + * Copyright (c) 2019-2022 Jannis Weis * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, @@ -79,7 +79,8 @@ public class DarkSplitButtonListener implements ActionListener, PropertyChangeLi @Override public void stateChanged(final ChangeEvent e) { ui.splitButton.repaint(); - if (!ui.splitButton.hasFocus() && ui.arrowButton.getModel().isPressed()) { + if (!ui.splitButton.hasFocus() && ui.arrowButton.isRequestFocusEnabled() + && ui.arrowButton.getModel().isPressed()) { ui.splitButton.requestFocusInWindow(); } }