* Handles a key down event (e.g. as fired by the key navigator).
*
* @param ne the key down event
*/
protected void onKeyDown(NativeEvent ne) {
XEvent e = ne.<XEvent> cast();
if (Element.is(ne.getEventTarget()) && !grid.getView().isSelectableTarget(Element.as(ne.getEventTarget()))) {
return;
}
if (listStore.size() == 0) {
return;
}
if (!e.getCtrlOrMetaKey() && selected.size() == 0 && getLastFocused() == null) {
select(0, false);
} else {
int idx = listStore.indexOf(getLastFocused());
if (idx >= 0 && (idx + 1) < listStore.size()) {
if (e.getCtrlOrMetaKey() || (e.getShiftKey() && isSelected(listStore.get(idx + 1)))) {
if (!e.getCtrlOrMetaKey()) {
deselect(idx);
}
M lF = listStore.get(idx + 1);
if (lF != null) {
setLastFocused(lF);
grid.getView().focusCell(idx + 1, 0, false);
}
} else {
if (e.getShiftKey() && lastSelected != getLastFocused()) {
grid.getView().focusCell(idx + 1, 0, false);
select(listStore.indexOf(lastSelected), idx + 1, true);
} else {
if (idx + 1 < listStore.size()) {
grid.getView().focusCell(idx + 1, 0, false);
selectNext(e.getShiftKey());
}
}
}
} else {
grid.getView().onNoNext(idx);
}
}
e.preventDefault();
}