Skip to content

Commit 2aa8218

Browse files
committed
8235480: Regression: [RTL] Arrow keys navigation doesn't respect TableView orientation
Reviewed-by: kcr, fastegal
1 parent e9c6119 commit 2aa8218

File tree

2 files changed

+428
-19
lines changed

2 files changed

+428
-19
lines changed

modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/behavior/TableViewBehaviorBase.java

+27-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -146,20 +146,20 @@ public TableViewBehaviorBase(C control) {
146146
new KeyMapping(PAGE_UP, e -> scrollUp()),
147147
new KeyMapping(PAGE_DOWN, e -> scrollDown()),
148148

149-
new KeyMapping(LEFT, e -> selectLeftCell()),
150-
new KeyMapping(KP_LEFT, e -> selectLeftCell()),
151-
new KeyMapping(RIGHT, e -> selectRightCell()),
152-
new KeyMapping(KP_RIGHT, e -> selectRightCell()),
149+
new KeyMapping(LEFT, e -> { if(isRTL()) selectRightCell(); else selectLeftCell(); }),
150+
new KeyMapping(KP_LEFT,e -> { if(isRTL()) selectRightCell(); else selectLeftCell(); }),
151+
new KeyMapping(RIGHT, e -> { if(isRTL()) selectLeftCell(); else selectRightCell(); }),
152+
new KeyMapping(KP_RIGHT, e -> { if(isRTL()) selectLeftCell(); else selectRightCell(); }),
153153

154154
new KeyMapping(UP, e -> selectPreviousRow()),
155155
new KeyMapping(KP_UP, e -> selectPreviousRow()),
156156
new KeyMapping(DOWN, e -> selectNextRow()),
157157
new KeyMapping(KP_DOWN, e -> selectNextRow()),
158158

159-
new KeyMapping(LEFT, FocusTraversalInputMap::traverseLeft),
160-
new KeyMapping(KP_LEFT, FocusTraversalInputMap::traverseLeft),
161-
new KeyMapping(RIGHT, FocusTraversalInputMap::traverseRight),
162-
new KeyMapping(KP_RIGHT, FocusTraversalInputMap::traverseRight),
159+
new KeyMapping(LEFT, e -> { if(isRTL()) focusTraverseRight(); else focusTraverseLeft(); }),
160+
new KeyMapping(KP_LEFT, e -> { if(isRTL()) focusTraverseRight(); else focusTraverseLeft(); }),
161+
new KeyMapping(RIGHT, e -> { if(isRTL()) focusTraverseLeft(); else focusTraverseRight(); }),
162+
new KeyMapping(KP_RIGHT, e -> { if(isRTL()) focusTraverseLeft(); else focusTraverseRight(); }),
163163
new KeyMapping(UP, FocusTraversalInputMap::traverseUp),
164164
new KeyMapping(KP_UP, FocusTraversalInputMap::traverseUp),
165165
new KeyMapping(DOWN, FocusTraversalInputMap::traverseDown),
@@ -178,17 +178,17 @@ public TableViewBehaviorBase(C control) {
178178
new KeyMapping(new KeyBinding(SPACE).shift(), e -> selectAllToFocus(false)),
179179
new KeyMapping(new KeyBinding(SPACE).shortcut().shift(), e -> selectAllToFocus(true)),
180180

181-
new KeyMapping(new KeyBinding(LEFT).shift(), e -> alsoSelectLeftCell()),
182-
new KeyMapping(new KeyBinding(KP_LEFT).shift(), e -> alsoSelectLeftCell()),
183-
new KeyMapping(new KeyBinding(RIGHT).shift(), e -> alsoSelectRightCell()),
184-
new KeyMapping(new KeyBinding(KP_RIGHT).shift(), e -> alsoSelectRightCell()),
181+
new KeyMapping(new KeyBinding(LEFT).shift(), e -> { if(isRTL()) alsoSelectRightCell(); else alsoSelectLeftCell(); }),
182+
new KeyMapping(new KeyBinding(KP_LEFT).shift(), e -> { if(isRTL()) alsoSelectRightCell(); else alsoSelectLeftCell(); }),
183+
new KeyMapping(new KeyBinding(RIGHT).shift(), e -> { if(isRTL()) alsoSelectLeftCell(); else alsoSelectRightCell(); }),
184+
new KeyMapping(new KeyBinding(KP_RIGHT).shift(), e -> { if(isRTL()) alsoSelectLeftCell(); else alsoSelectRightCell(); }),
185185

186186
new KeyMapping(new KeyBinding(UP).shortcut(), e -> focusPreviousRow()),
187187
new KeyMapping(new KeyBinding(DOWN).shortcut(), e -> focusNextRow()),
188-
new KeyMapping(new KeyBinding(RIGHT).shortcut(), e -> focusRightCell()),
189-
new KeyMapping(new KeyBinding(KP_RIGHT).shortcut(), e -> focusRightCell()),
190-
new KeyMapping(new KeyBinding(LEFT).shortcut(), e -> focusLeftCell()),
191-
new KeyMapping(new KeyBinding(KP_LEFT).shortcut(), e -> focusLeftCell()),
188+
new KeyMapping(new KeyBinding(RIGHT).shortcut(), e -> { if(isRTL()) focusLeftCell(); else focusRightCell(); }),
189+
new KeyMapping(new KeyBinding(KP_RIGHT).shortcut(), e -> { if(isRTL()) focusLeftCell(); else focusRightCell(); }),
190+
new KeyMapping(new KeyBinding(LEFT).shortcut(), e -> { if(isRTL()) focusRightCell(); else focusLeftCell(); }),
191+
new KeyMapping(new KeyBinding(KP_LEFT).shortcut(), e -> { if(isRTL()) focusRightCell(); else focusLeftCell(); }),
192192

193193
new KeyMapping(new KeyBinding(A).shortcut(), e -> selectAll()),
194194
new KeyMapping(new KeyBinding(HOME).shortcut(), e -> focusFirstRow()),
@@ -198,8 +198,8 @@ public TableViewBehaviorBase(C control) {
198198

199199
new KeyMapping(new KeyBinding(UP).shortcut().shift(), e -> discontinuousSelectPreviousRow()),
200200
new KeyMapping(new KeyBinding(DOWN).shortcut().shift(), e -> discontinuousSelectNextRow()),
201-
new KeyMapping(new KeyBinding(LEFT).shortcut().shift(), e -> discontinuousSelectPreviousColumn()),
202-
new KeyMapping(new KeyBinding(RIGHT).shortcut().shift(), e -> discontinuousSelectNextColumn()),
201+
new KeyMapping(new KeyBinding(LEFT).shortcut().shift(), e -> { if(isRTL()) discontinuousSelectNextColumn(); else discontinuousSelectPreviousColumn(); }),
202+
new KeyMapping(new KeyBinding(RIGHT).shortcut().shift(), e -> { if(isRTL()) discontinuousSelectPreviousColumn(); else discontinuousSelectNextColumn(); }),
203203
new KeyMapping(new KeyBinding(PAGE_UP).shortcut().shift(), e -> discontinuousSelectPageUp()),
204204
new KeyMapping(new KeyBinding(PAGE_DOWN).shortcut().shift(), e -> discontinuousSelectPageDown()),
205205
new KeyMapping(new KeyBinding(HOME).shortcut().shift(), e -> discontinuousSelectAllToFirstRow()),
@@ -1309,4 +1309,12 @@ protected void discontinuousSelectAllToLastRow() {
13091309

13101310
if (onMoveToLastCell != null) onMoveToLastCell.run();
13111311
}
1312+
1313+
private EventHandler<KeyEvent> focusTraverseLeft() {
1314+
return FocusTraversalInputMap::traverseLeft;
1315+
}
1316+
1317+
private EventHandler<KeyEvent> focusTraverseRight() {
1318+
return FocusTraversalInputMap::traverseRight;
1319+
}
13121320
}

0 commit comments

Comments
 (0)