summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-09-15 14:21:20 +0300
committerTeemu Suo-Anttila <teemusa@vaadin.com>2015-09-16 12:10:45 +0300
commita11bd16d7aa525b2ab561337e3b2ffb2ad77604b (patch)
tree6902316730b53cde39ae668f4543ed0da8d8f350
parent5a876aba43f3fdb3020a559e8929aa9667c25161 (diff)
downloadvaadin-framework-a11bd16d7aa525b2ab561337e3b2ffb2ad77604b.tar.gz
vaadin-framework-a11bd16d7aa525b2ab561337e3b2ffb2ad77604b.zip
Add Tab move to next/previous row in Editor (#16841)
Change-Id: I142d7e70cd226f01905f34440b6ec5096eaa86d7
-rw-r--r--client/src/com/vaadin/client/widget/grid/DefaultEditorEventHandler.java25
1 files changed, 22 insertions, 3 deletions
diff --git a/client/src/com/vaadin/client/widget/grid/DefaultEditorEventHandler.java b/client/src/com/vaadin/client/widget/grid/DefaultEditorEventHandler.java
index d607701d19..f5ddbccaf4 100644
--- a/client/src/com/vaadin/client/widget/grid/DefaultEditorEventHandler.java
+++ b/client/src/com/vaadin/client/widget/grid/DefaultEditorEventHandler.java
@@ -158,7 +158,7 @@ public class DefaultEditorEventHandler<T> implements Editor.EventHandler<T> {
int colDelta = 0;
if (e.getKeyCode() == KEYCODE_MOVE_VERTICAL) {
- rowDelta += (e.getShiftKey() ? -1 : +1);
+ rowDelta = (e.getShiftKey() ? -1 : +1);
} else if (e.getKeyCode() == KEYCODE_MOVE_HORIZONTAL) {
colDelta = (e.getShiftKey() ? -1 : +1);
}
@@ -166,8 +166,27 @@ public class DefaultEditorEventHandler<T> implements Editor.EventHandler<T> {
final boolean changed = rowDelta != 0 || colDelta != 0;
if (changed) {
- editRow(event, event.getRowIndex() + rowDelta,
- event.getFocusedColumnIndex() + colDelta);
+
+ int columnCount = event.getGrid().getVisibleColumns().size();
+
+ int colIndex = event.getFocusedColumnIndex() + colDelta;
+ int rowIndex = event.getRowIndex();
+
+ // Handle row change with horizontal move when column goes out
+ // of range.
+ if (rowDelta == 0) {
+ if (colIndex >= columnCount
+ && rowIndex < event.getGrid().getDataSource()
+ .size() - 1) {
+ rowDelta = 1;
+ colIndex = 0;
+ } else if (colIndex < 0 && rowIndex > 0) {
+ rowDelta = -1;
+ colIndex = columnCount - 1;
+ }
+ }
+
+ editRow(event, rowIndex + rowDelta, colIndex);
// FIXME should be in editRow
event.getGrid().fireEvent(new EditorMoveEvent(cell));