I'd like to intercept Ctrl+F4 in order to close tabs of a TabPanel rather then the browser tab my application is running in. The following code is works if I click inside the tab panel first:
Viewport v = new Viewport();
v.setLayout(new FitLayout());
v.add(panel);
v.addListener(Events.KeyDown, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
KeyEvent ce = (KeyEvent)be;
if (ce.isControlKey()) {
if (ce.getKeyCode() == 115) {
System.out.println(ce.getKeyCode() + " Ctrl-f4");
ce.preventDefault();
ce.stopEvent();
}
}
};
});
The funny thing is that if the focus is somewhre outside the TabPanel (which is obviously located inside the Viewport) the event isn't fired.
Any ideas?