I'm trying to change the row highlighting in my FlexTable using KeyCodes.KEY_UP/DOWN. This doesn't seem to work (based on 1809155):
public class KeyAwareFlexTable extends FlexTable
implements KeyDownHandler, HasKeyDownHandlers {
public KeyAwareFlexTable() {
this.addKeyDownHandler(this);
}
@Override
public void onKeyDown(KeyDownEvent event) {
GWT.log("onKeyDown");
// check if up/down & do something useful
}
@Override
public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
return addDomHandler(handler, KeyDownEvent.getType());
}
}
I've also tried this (based on this site):
FlexTable table = new FlexTable() {
@Override
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
GWT.log("Event type = " + DOM.eventGetType(event));
switch (DOM.eventGetType(event)) {
case Event.ONKEYDOWN:
if (DOM.eventGetKeyCode(event) == KeyCodes.KEY_UP) {
GWT.log("up");
} else if (DOM.eventGetKeyCode(event) == KeyCodes.KEY_DOWN) {
GWT.log("down");
}
break;
default:
break;
}
}
};
table.sinkEvents(Event.ONKEYDOWN);
I'm looking for a way to have this behavior more or less. Does anybody have a way to do this in GWT?