Browse Source

Button: Implicitly set isRequestFocusEnabled to false for borderless variants

pull/323/head
Jannis Weis 3 years ago
parent
commit
eba80e3f36
No known key found for this signature in database
GPG Key ID: 7C9D8D4B558049AB
  1. 12
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonListener.java

12
core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonListener.java

@ -1,7 +1,7 @@
/* /*
* MIT License * MIT License
* *
* Copyright (c) 2020-2021 Jannis Weis * Copyright (c) 2020-2022 Jannis Weis
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * 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, * associated documentation files (the "Software"), to deal in the Software without restriction,
@ -87,6 +87,16 @@ public class DarkButtonListener<T extends DarkButtonUI> extends BasicButtonListe
ui.updateMargins(b); ui.updateMargins(b);
b.doLayout(); b.doLayout();
b.repaint(); b.repaint();
if (ButtonConstants.KEY_VARIANT.equals(key)) {
// We only have to check the explicit variant, as automatic conversion implies the button is
// non-focusable anyway.
boolean oldWasBorderless = ButtonConstants.VARIANT_BORDERLESS.equals(e.getOldValue())
|| ButtonConstants.VARIANT_BORDERLESS_RECTANGULAR.equals(e.getOldValue());
boolean newIsBorderless = ButtonConstants.isBorderless(b) || ButtonConstants.isBorderlessRectangular(b);
if (oldWasBorderless || newIsBorderless) {
b.setRequestFocusEnabled(!newIsBorderless);
}
}
} }
} }
} }

Loading…
Cancel
Save