@Override
        public void onCellPreview(CellPreviewEvent<T> event) {
            NativeEvent nativeEvent = event.getNativeEvent();
            String eventType = event.getNativeEvent().getType();
            if (BrowserEvents.KEYDOWN.equals(eventType) && !event.isCellEditing()) {
                /*
                 * Handle keyboard navigation, unless the cell is being edited. If the
                 * cell is being edited, we do not want to change rows.
                 *
                 * Prevent default on navigation events to prevent default scrollbar
                 * behavior.
                 */
                int oldRow = table.getKeyboardSelectedRow();
                int oldColumn = table.getKeyboardSelectedColumn();
                boolean isRtl = LocaleInfo.getCurrentLocale().isRTL();
                int keyCodeLineEnd = isRtl
                        ? KeyCodes.KEY_LEFT
                        : KeyCodes.KEY_RIGHT;
                int keyCodeLineStart = isRtl
                        ? KeyCodes.KEY_RIGHT
                        : KeyCodes.KEY_LEFT;
                int keyCode = nativeEvent.getKeyCode();
                if (keyCode == keyCodeLineEnd) {
                    int nextColumn = findInteractiveColumn(oldColumn, false);
                    if (nextColumn <= oldColumn) {
                        // Wrap to the next row.
                        table.setKeyboardSelectedRow(oldRow + 1);
                        if (table.getKeyboardSelectedRow() != oldRow) {
                            // If the row didn't change, we are at the end of the table.
                            table.setKeyboardSelectedColumn(nextColumn);
                            handledEvent(event);
                            return;
                        }
                    } else {
                        table.setKeyboardSelectedColumn(nextColumn);
                        handledEvent(event);
                        return;
                    }
                } else if (keyCode == keyCodeLineStart) {
                    int prevColumn = findInteractiveColumn(oldColumn, true);
                    if (prevColumn >= oldColumn) {
                        // Wrap to the previous row.
                        table.setKeyboardSelectedRow(oldRow - 1);
                        if (table.getKeyboardSelectedRow() != oldRow) {
                            // If the row didn't change, we are at the start of the table.
                            table.setKeyboardSelectedColumn(prevColumn);
                            handledEvent(event);
                            return;
                        }
                    } else {
                        table.setKeyboardSelectedColumn(prevColumn);
                        handledEvent(event);
                        return;
                    }
                }
            } else if (BrowserEvents.CLICK.equals(eventType) || BrowserEvents.FOCUS.equals(eventType)) {
                /*
                 * Move keyboard focus to the clicked column, even if the cell is being
                 * edited. Unlike key events, we aren't moving the currently selected
                 * row, just updating it based on where the user clicked.
                 *
                 * Since the user clicked, allow focus to go to a non-interactive
                 * column.
                 */
                int col = event.getColumn();
                int relRow = event.getIndex() - table.getPageStart();
                int subrow = event.getContext().getSubIndex();
                if ((table.getKeyboardSelectedColumn() != col)
                    || (table.getKeyboardSelectedRow() != relRow)
                    || (table.getKeyboardSelectedSubRow() != subrow)) {
                    boolean stealFocus = false;
                    if (BrowserEvents.CLICK.equals(eventType)) {
                        // If a natively focusable element was just clicked, then do not
                        // steal focus.
                        Element target = Element.as(event.getNativeEvent().getEventTarget());
                        stealFocus = !CellBasedWidgetImpl.get().isFocusable(target);
                    }

                    // Update the row and subrow.
                    table.setKeyboardSelectedRow(relRow, subrow, stealFocus);

                    // Update the column index.
                    table.setKeyboardSelectedColumn(col, stealFocus);
                }

                // Do not cancel the event as the click may have occurred on a Cell.
                return;
            }

            // Let the parent class handle the event.
            super.onCellPreview(event);
        }
Construct a new keyboard selection handler for the specified table.

@param table the display being handled
stroom-core-client-widget/src/main/java/com/google/gwt/user/cellview/client/AbstractCellTable.java