reviewed (and tested) all key bindings on macOS

This commit is contained in:
Karl Tauber
2020-03-16 15:20:17 +01:00
parent df1634de3d
commit 2608061d48
6 changed files with 96 additions and 113 deletions

View File

@@ -48,10 +48,10 @@ class FlatInputMaps
modifyInputMap( defaults, "ComboBox.ancestorInputMap",
"SPACE", "spacePopup",
"UP", "selectPrevious2",
"DOWN", "selectNext2",
"KP_UP", "selectPrevious2",
"KP_DOWN", "selectNext2",
"UP", mac( "selectPrevious2", "selectPrevious" ),
"DOWN", mac( "selectNext2", "selectNext" ),
"KP_UP", mac( "selectPrevious2", "selectPrevious" ),
"KP_DOWN", mac( "selectNext2", "selectNext" ),
mac( "alt UP", null ), "togglePopup",
mac( "alt DOWN", null ), "togglePopup",
@@ -182,7 +182,7 @@ class FlatInputMaps
"ctrl A", beginLineAction,
"ctrl E", endLineAction,
// move caret to document begin/end (without selecting text)
// move caret to document begin/end and select text
"shift meta UP", selectionBeginAction,
"shift meta DOWN", selectionEndAction,
"shift meta KP_UP", selectionBeginAction,
@@ -198,16 +198,6 @@ class FlatInputMaps
"shift KP_UP", selectionBeginLineAction,
"shift KP_DOWN", selectionEndLineAction,
// move caret one page (without selecting text)
"PAGE_UP", pageUpAction,
"PAGE_DOWN", pageDownAction,
// move caret one page and select text
"shift PAGE_UP", "selection-page-up", // DefaultEditorKit.selectionPageUpAction
"shift PAGE_DOWN", "selection-page-down", // DefaultEditorKit.selectionPageDownAction
"shift meta PAGE_UP", "selection-page-left", // DefaultEditorKit.selectionPageLeftAction
"shift meta PAGE_DOWN", "selection-page-right", // DefaultEditorKit.selectionPageRightAction
// delete previous/next word
"ctrl W", deletePrevWordAction,
"ctrl D", deleteNextCharAction,
@@ -350,6 +340,12 @@ class FlatInputMaps
"meta V", "paste",
"meta X", "cut",
// let parent scroll pane do the macOS typical scrolling without changing selection
"HOME", null,
"END", null,
"PAGE_UP", null,
"PAGE_DOWN", null,
"ctrl A", null,
"ctrl BACK_SLASH", null,
"ctrl C", null,
@@ -370,8 +366,6 @@ class FlatInputMaps
"ctrl UP", null,
"ctrl V", null,
"ctrl X", null,
"PAGE_DOWN", null,
"PAGE_UP", null,
"SPACE", null,
"shift ctrl DOWN", null,
"shift ctrl END", null,
@@ -390,10 +384,16 @@ class FlatInputMaps
"shift INSERT", null,
"shift SPACE", null
);
// scrollbar
copyInputMap( defaults, "ScrollBar.ancestorInputMap", "ScrollBar.focusInputMap" );
copyInputMap( defaults, "ScrollBar.ancestorInputMap.RightToLeft", "ScrollBar.focusInputMap.RightToLeft" );
modifyInputMap( defaults, "List.focusInputMap.RightToLeft",
"ctrl KP_LEFT", null,
"ctrl KP_RIGHT", null,
"ctrl LEFT", null,
"ctrl RIGHT", null,
"shift ctrl KP_LEFT", null,
"shift ctrl KP_RIGHT", null,
"shift ctrl LEFT", null,
"shift ctrl RIGHT", null
);
// scrollpane
modifyInputMap( defaults, "ScrollPane.ancestorInputMap",
@@ -410,6 +410,16 @@ class FlatInputMaps
"ctrl PAGE_UP", null
);
// tabbedpane
modifyInputMap( defaults, "TabbedPane.ancestorInputMap",
"ctrl UP", null,
"ctrl KP_UP", null
);
modifyInputMap( defaults, "TabbedPane.focusInputMap",
"ctrl DOWN", null,
"ctrl KP_DOWN", null
);
// table
modifyInputMap( defaults, "Table.ancestorInputMap",
"alt TAB", "focusHeader",
@@ -419,6 +429,12 @@ class FlatInputMaps
"meta V", "paste",
"meta X", "cut",
// let parent scroll pane do the macOS typical scrolling without changing selection
"HOME", null,
"END", null,
"PAGE_UP", null,
"PAGE_DOWN", null,
"ctrl A", null,
"ctrl BACK_SLASH", null,
"ctrl C", null,
@@ -476,27 +492,31 @@ class FlatInputMaps
"RIGHT", "selectChild",
"KP_LEFT", "selectParent",
"KP_RIGHT", "selectChild",
"shift LEFT", "selectParent",
"shift RIGHT", "selectChild",
"shift KP_LEFT", "selectParent",
"shift KP_RIGHT", "selectChild",
"alt LEFT", "selectParent",
"alt RIGHT", "selectChild",
"alt KP_LEFT", "selectParent",
"alt KP_RIGHT", "selectChild",
"meta A", "selectAll",
"meta C", "copy",
"meta V", "paste",
"meta X", "cut",
// let parent scroll pane do the macOS typical scrolling without changing selection
"HOME", null,
"END", null,
"PAGE_UP", null,
"PAGE_DOWN", null,
"ctrl LEFT", null,
"ctrl RIGHT", null,
"ctrl KP_LEFT", null,
"ctrl KP_RIGHT", null,
"shift LEFT", null,
"shift RIGHT", null,
"shift KP_LEFT", null,
"shift KP_RIGHT", null,
"alt LEFT", null,
"alt RIGHT", null,
"alt KP_LEFT", null,
"alt KP_RIGHT", null,
"ctrl A", null,
"ctrl BACK_SLASH", null,
"ctrl C", null,
@@ -513,11 +533,7 @@ class FlatInputMaps
"ctrl UP", null,
"ctrl V", null,
"ctrl X", null,
"END", null,
"F2", null,
"HOME", null,
"PAGE_DOWN", null,
"PAGE_UP", null,
"SPACE", null,
"shift ctrl DOWN", null,
"shift ctrl END", null,
@@ -540,17 +556,18 @@ class FlatInputMaps
"LEFT", "selectChild",
"RIGHT", "selectParent",
"KP_LEFT", "selectChild",
"KP_RIGHT", "selectParent"
"KP_RIGHT", "selectParent",
"shift LEFT", "selectChild",
"shift RIGHT", "selectParent",
"shift KP_LEFT", "selectChild",
"shift KP_RIGHT", "selectParent",
"alt LEFT", "selectChild",
"alt RIGHT", "selectParent",
"alt KP_LEFT", "selectChild",
"alt KP_RIGHT", "selectParent"
} ) );
}
private static void copyInputMap( UIDefaults defaults, String srcKey, String destKey ) {
// Note: not using `defaults.get(key)` here because this would resolve the lazy value
Object inputMap = defaults.remove( srcKey );
defaults.put( srcKey, inputMap );
defaults.put( destKey, inputMap );
}
private static void modifyInputMap( UIDefaults defaults, String key, Object... bindings ) {
// Note: not using `defaults.get(key)` here because this would resolve the lazy value
defaults.put( key, new LazyModifyInputMap( defaults.remove( key ), bindings ) );

View File

@@ -281,13 +281,14 @@ public class FlatComboBoxUI
// macOS
if( SystemInfo.IS_MAC && editor instanceof JTextComponent ) {
// delegate actions from editor text field to combobox, which is necessary
// because text field on macOS (based on Aqua LaF UI defaults)
// already handle those keys
// because text field on macOS already handle those keys
InputMap inputMap = ((JTextComponent)editor).getInputMap();
new EditorDelegateAction( inputMap, KeyStroke.getKeyStroke( "UP" ) );
new EditorDelegateAction( inputMap, KeyStroke.getKeyStroke( "KP_UP" ) );
new EditorDelegateAction( inputMap, KeyStroke.getKeyStroke( "DOWN" ) );
new EditorDelegateAction( inputMap, KeyStroke.getKeyStroke( "KP_DOWN" ) );
new EditorDelegateAction( inputMap, KeyStroke.getKeyStroke( "HOME" ) );
new EditorDelegateAction( inputMap, KeyStroke.getKeyStroke( "END" ) );
}
}

View File

@@ -178,6 +178,7 @@ ColorChooser.swatchesDefaultRecentColor=$control
ComboBox.border=com.formdev.flatlaf.ui.FlatRoundBorder
ComboBox.padding=2,6,2,6
[mac]ComboBox.showPopupOnNavigation=true
#---- Component ----

View File

@@ -192,6 +192,7 @@ ComboBox.noActionOnKeyNavigation false
ComboBox.padding 2,6,2,6 javax.swing.plaf.InsetsUIResource [UI]
ComboBox.selectionBackground #4b6eaf javax.swing.plaf.ColorUIResource [UI]
ComboBox.selectionForeground #bbbbbb javax.swing.plaf.ColorUIResource [UI]
ComboBox.showPopupOnNavigation true
ComboBox.timeFactor 1000
ComboBoxUI com.formdev.flatlaf.ui.FlatComboBoxUI

View File

@@ -193,6 +193,7 @@ ComboBox.noActionOnKeyNavigation false
ComboBox.padding 2,6,2,6 javax.swing.plaf.InsetsUIResource [UI]
ComboBox.selectionBackground #2675bf javax.swing.plaf.ColorUIResource [UI]
ComboBox.selectionForeground #ffffff javax.swing.plaf.ColorUIResource [UI]
ComboBox.showPopupOnNavigation true
ComboBox.timeFactor 1000
ComboBoxUI com.formdev.flatlaf.ui.FlatComboBoxUI

View File

@@ -22,17 +22,17 @@ CheckBox.focusInputMap [lazy] 2 javax.swing.plaf.InputMapUIResource [
#---- ComboBox ----
ComboBox.ancestorInputMap [lazy] 11 javax.swing.plaf.InputMapUIResource [UI]
DOWN selectNext2
DOWN selectNext
END endPassThrough
ENTER enterPressed
ESCAPE hidePopup
HOME homePassThrough
KP_DOWN selectNext2
KP_UP selectPrevious2
KP_DOWN selectNext
KP_UP selectPrevious
PAGE_DOWN pageDownPassThrough
PAGE_UP pageUpPassThrough
SPACE spacePopup
UP selectPrevious2
UP selectPrevious
#---- Desktop ----
@@ -166,7 +166,7 @@ FileChooser.ancestorInputMap [lazy] 2 javax.swing.plaf.InputMapUIResource [
#---- FormattedTextField ----
FormattedTextField.focusInputMap [lazy] 76 javax.swing.plaf.InputMapUIResource [UI]
FormattedTextField.focusInputMap [lazy] 70 javax.swing.plaf.InputMapUIResource [UI]
alt BACK_SPACE delete-previous-word
alt DELETE delete-next-word
alt KP_LEFT caret-previous-word
@@ -210,8 +210,6 @@ FormattedTextField.focusInputMap [lazy] 76 javax.swing.plaf.InputMapUIResourc
KP_RIGHT caret-forward
KP_UP increment
LEFT caret-backward
PAGE_DOWN page-down
PAGE_UP page-up
PASTE paste-from-clipboard
RIGHT caret-forward
UP increment
@@ -226,8 +224,6 @@ FormattedTextField.focusInputMap [lazy] 76 javax.swing.plaf.InputMapUIResourc
shift meta KP_RIGHT selection-end-line
shift meta KP_UP selection-begin
shift meta LEFT selection-begin-line
shift meta PAGE_DOWN selection-page-right
shift meta PAGE_UP selection-page-left
shift meta RIGHT selection-end-line
shift meta UP selection-begin
shift BACK_SPACE delete-previous
@@ -239,32 +235,22 @@ FormattedTextField.focusInputMap [lazy] 76 javax.swing.plaf.InputMapUIResourc
shift KP_RIGHT selection-forward
shift KP_UP selection-begin-line
shift LEFT selection-backward
shift PAGE_DOWN selection-page-down
shift PAGE_UP selection-page-up
shift RIGHT selection-forward
shift UP selection-begin-line
#---- List ----
List.focusInputMap.RightToLeft [lazy] 16 javax.swing.plaf.InputMapUIResource [UI]
ctrl KP_LEFT selectNextColumnChangeLead
ctrl KP_RIGHT selectPreviousColumnChangeLead
ctrl LEFT selectNextColumnChangeLead
ctrl RIGHT selectPreviousColumnChangeLead
List.focusInputMap.RightToLeft [lazy] 8 javax.swing.plaf.InputMapUIResource [UI]
KP_LEFT selectNextColumn
KP_RIGHT selectPreviousColumn
LEFT selectNextColumn
RIGHT selectPreviousColumn
shift ctrl KP_LEFT selectNextColumnExtendSelection
shift ctrl KP_RIGHT selectPreviousColumnExtendSelection
shift ctrl LEFT selectNextColumnExtendSelection
shift ctrl RIGHT selectPreviousColumnExtendSelection
shift KP_LEFT selectNextColumnExtendSelection
shift KP_RIGHT selectPreviousColumnExtendSelection
shift LEFT selectNextColumnExtendSelection
shift RIGHT selectPreviousColumnExtendSelection
List.focusInputMap [lazy] 29 javax.swing.plaf.InputMapUIResource [UI]
List.focusInputMap [lazy] 27 javax.swing.plaf.InputMapUIResource [UI]
meta A selectAll
meta C copy
meta V paste
@@ -272,8 +258,6 @@ List.focusInputMap [lazy] 29 javax.swing.plaf.InputMapUIResource
COPY copy
CUT cut
DOWN selectNextRow
END selectLastRow
HOME selectFirstRow
KP_DOWN selectNextRow
KP_LEFT selectPreviousColumn
KP_RIGHT selectNextColumn
@@ -298,7 +282,7 @@ List.focusInputMap [lazy] 29 javax.swing.plaf.InputMapUIResource
#---- PasswordField ----
PasswordField.focusInputMap [lazy] 73 javax.swing.plaf.InputMapUIResource [UI]
PasswordField.focusInputMap [lazy] 67 javax.swing.plaf.InputMapUIResource [UI]
alt KP_LEFT caret-begin-line
alt KP_RIGHT caret-end-line
alt LEFT caret-begin-line
@@ -339,8 +323,6 @@ PasswordField.focusInputMap [lazy] 73 javax.swing.plaf.InputMapUIResource
KP_RIGHT caret-forward
KP_UP caret-begin-line
LEFT caret-backward
PAGE_DOWN page-down
PAGE_UP page-up
PASTE paste-from-clipboard
RIGHT caret-forward
UP caret-begin-line
@@ -355,8 +337,6 @@ PasswordField.focusInputMap [lazy] 73 javax.swing.plaf.InputMapUIResource
shift meta KP_RIGHT selection-end-line
shift meta KP_UP selection-begin
shift meta LEFT selection-begin-line
shift meta PAGE_DOWN selection-page-right
shift meta PAGE_UP selection-page-left
shift meta RIGHT selection-end-line
shift meta UP selection-begin
shift BACK_SPACE delete-previous
@@ -368,8 +348,6 @@ PasswordField.focusInputMap [lazy] 73 javax.swing.plaf.InputMapUIResource
shift KP_RIGHT selection-forward
shift KP_UP selection-begin-line
shift LEFT selection-backward
shift PAGE_DOWN selection-page-down
shift PAGE_UP selection-page-up
shift RIGHT selection-forward
shift UP selection-begin-line
@@ -470,24 +448,6 @@ ScrollBar.ancestorInputMap [lazy] 12 javax.swing.plaf.InputMapUIResource
PAGE_UP negativeBlockIncrement
RIGHT positiveUnitIncrement
UP negativeUnitIncrement
ScrollBar.focusInputMap.RightToLeft [lazy] 4 javax.swing.plaf.InputMapUIResource [UI]
KP_LEFT positiveUnitIncrement
KP_RIGHT negativeUnitIncrement
LEFT positiveUnitIncrement
RIGHT negativeUnitIncrement
ScrollBar.focusInputMap [lazy] 12 javax.swing.plaf.InputMapUIResource [UI]
DOWN positiveUnitIncrement
END maxScroll
HOME minScroll
KP_DOWN positiveUnitIncrement
KP_LEFT negativeUnitIncrement
KP_RIGHT positiveUnitIncrement
KP_UP negativeUnitIncrement
LEFT negativeUnitIncrement
PAGE_DOWN positiveBlockIncrement
PAGE_UP negativeBlockIncrement
RIGHT positiveUnitIncrement
UP negativeUnitIncrement
#---- ScrollPane ----
@@ -560,16 +520,12 @@ SplitPane.ancestorInputMap [lazy] 14 javax.swing.plaf.InputMapUIResource
#---- TabbedPane ----
TabbedPane.ancestorInputMap [lazy] 6 javax.swing.plaf.InputMapUIResource [UI]
ctrl KP_UP requestFocus
TabbedPane.ancestorInputMap [lazy] 4 javax.swing.plaf.InputMapUIResource [UI]
ctrl PAGE_DOWN navigatePageDown
ctrl PAGE_UP navigatePageUp
ctrl TAB navigateNext
ctrl UP requestFocus
shift ctrl TAB navigatePrevious
TabbedPane.focusInputMap [lazy] 10 javax.swing.plaf.InputMapUIResource [UI]
ctrl DOWN requestFocusForVisibleComponent
ctrl KP_DOWN requestFocusForVisibleComponent
TabbedPane.focusInputMap [lazy] 8 javax.swing.plaf.InputMapUIResource [UI]
DOWN navigateDown
KP_DOWN navigateDown
KP_LEFT navigateLeft
@@ -595,7 +551,7 @@ Table.ancestorInputMap.RightToLeft [lazy] 12 javax.swing.plaf.InputMapUIResou
shift KP_RIGHT selectPreviousColumnExtendSelection
shift LEFT selectNextColumnExtendSelection
shift RIGHT selectPreviousColumnExtendSelection
Table.ancestorInputMap [lazy] 38 javax.swing.plaf.InputMapUIResource [UI]
Table.ancestorInputMap [lazy] 34 javax.swing.plaf.InputMapUIResource [UI]
alt TAB focusHeader
meta A selectAll
meta C copy
@@ -604,17 +560,13 @@ Table.ancestorInputMap [lazy] 38 javax.swing.plaf.InputMapUIResource
COPY copy
CUT cut
DOWN selectNextRow
END selectLastRow
ENTER selectNextRowCell
ESCAPE cancel
HOME selectFirstRow
KP_DOWN selectNextRow
KP_LEFT selectPreviousColumn
KP_RIGHT selectNextColumn
KP_UP selectPreviousRow
LEFT selectPreviousColumn
PAGE_DOWN scrollDownChangeSelection
PAGE_UP scrollUpChangeSelection
PASTE paste
RIGHT selectNextColumn
TAB selectNextColumnCell
@@ -745,7 +697,7 @@ TextArea.focusInputMap [lazy] 83 javax.swing.plaf.InputMapUIResource
#---- TextField ----
TextField.focusInputMap [lazy] 75 javax.swing.plaf.InputMapUIResource [UI]
TextField.focusInputMap [lazy] 69 javax.swing.plaf.InputMapUIResource [UI]
alt BACK_SPACE delete-previous-word
alt DELETE delete-next-word
alt KP_LEFT caret-previous-word
@@ -788,8 +740,6 @@ TextField.focusInputMap [lazy] 75 javax.swing.plaf.InputMapUIResource
KP_RIGHT caret-forward
KP_UP caret-begin-line
LEFT caret-backward
PAGE_DOWN page-down
PAGE_UP page-up
PASTE paste-from-clipboard
RIGHT caret-forward
UP caret-begin-line
@@ -804,8 +754,6 @@ TextField.focusInputMap [lazy] 75 javax.swing.plaf.InputMapUIResource
shift meta KP_RIGHT selection-end-line
shift meta KP_UP selection-begin
shift meta LEFT selection-begin-line
shift meta PAGE_DOWN selection-page-right
shift meta PAGE_UP selection-page-left
shift meta RIGHT selection-end-line
shift meta UP selection-begin
shift BACK_SPACE delete-previous
@@ -817,8 +765,6 @@ TextField.focusInputMap [lazy] 75 javax.swing.plaf.InputMapUIResource
shift KP_RIGHT selection-forward
shift KP_UP selection-begin-line
shift LEFT selection-backward
shift PAGE_DOWN selection-page-down
shift PAGE_UP selection-page-up
shift RIGHT selection-forward
shift UP selection-begin-line
@@ -935,12 +881,24 @@ ToolBar.ancestorInputMap [lazy] 8 javax.swing.plaf.InputMapUIResource [
Tree.ancestorInputMap [lazy] 1 javax.swing.plaf.InputMapUIResource [UI]
ESCAPE cancel
Tree.focusInputMap.RightToLeft [lazy] 4 javax.swing.plaf.InputMapUIResource [UI]
Tree.focusInputMap.RightToLeft [lazy] 12 javax.swing.plaf.InputMapUIResource [UI]
alt KP_LEFT selectChild
alt KP_RIGHT selectParent
alt LEFT selectChild
alt RIGHT selectParent
KP_LEFT selectChild
KP_RIGHT selectParent
LEFT selectChild
RIGHT selectParent
Tree.focusInputMap [lazy] 19 javax.swing.plaf.InputMapUIResource [UI]
shift KP_LEFT selectChild
shift KP_RIGHT selectParent
shift LEFT selectChild
shift RIGHT selectParent
Tree.focusInputMap [lazy] 27 javax.swing.plaf.InputMapUIResource [UI]
alt KP_LEFT selectParent
alt KP_RIGHT selectChild
alt LEFT selectParent
alt RIGHT selectChild
meta A selectAll
meta C copy
meta V paste
@@ -958,5 +916,9 @@ Tree.focusInputMap [lazy] 19 javax.swing.plaf.InputMapUIResource
UP selectPrevious
shift DOWN selectNextExtendSelection
shift KP_DOWN selectNextExtendSelection
shift KP_LEFT selectParent
shift KP_RIGHT selectChild
shift KP_UP selectPreviousExtendSelection
shift LEFT selectParent
shift RIGHT selectChild
shift UP selectPreviousExtendSelection