Button: fixed behavior of Enter key on focused button on Windows and Linux, which now clicks the focused button (instead of the default button)

This commit is contained in:
Karl Tauber
2021-01-30 00:37:20 +01:00
parent dc570c683a
commit 036090a947
4 changed files with 19 additions and 5 deletions

View File

@@ -14,6 +14,14 @@ FlatLaf Change Log
#### Fixed bugs
- Button: Fixed behavior of <kbd>Enter</kbd> key on focused button on Windows
and Linux, which now clicks the focused button (instead of the default
button).
- On Windows, this is a regression in 1.0-rc1.
- On macOS, the <kbd>Enter</kbd> key always clicks the default button, which
is the platform behavior.
- On all platforms, the default button can be always clicked with
<kbd>Ctrl+Enter</kbd> keys, even if another button is focused.
- CheckBox and RadioButton: Fill component background as soon as background
color is different to default background color, even if component is not
opaque (which is the default). This paints selection if using the component as

View File

@@ -42,10 +42,12 @@ class FlatInputMaps
}
private static void initBasicInputMaps( UIDefaults defaults ) {
defaults.put( "Button.focusInputMap", new UIDefaults.LazyInputMap( new Object[] {
"SPACE", "pressed",
"released SPACE", "released"
} ) );
if( SystemInfo.isMacOS ) {
defaults.put( "Button.focusInputMap", new UIDefaults.LazyInputMap( new Object[] {
"SPACE", "pressed",
"released SPACE", "released"
} ) );
}
modifyInputMap( defaults, "ComboBox.ancestorInputMap",
"SPACE", "spacePopup",

View File

@@ -44,10 +44,12 @@ class NewDialog
}
private void okActionPerformed() {
System.out.println( "ok" );
dispose();
}
private void cancelActionPerformed() {
System.out.println( "cancel" );
dispose();
}

View File

@@ -7,8 +7,10 @@ OS Windows 10
#---- Button ----
Button.focusInputMap [lazy] 2 javax.swing.plaf.InputMapUIResource [UI]
Button.focusInputMap [lazy] 4 javax.swing.plaf.InputMapUIResource [UI]
ENTER pressed
SPACE pressed
released ENTER released
released SPACE released