@Override public void onKeyDown(KeyDownEvent event) { ignoreNextKeyPress = true; Event nativeEvent = (Event) event.getNativeEvent(); if (!nativeEvent.isCancelled()) { handleRepeatableKey(nativeEvent); } cancelNextKeyPress = nativeEvent.isCancelled(); }
@Override public void onKeyUp(KeyUpEvent event) { ignoreNextKeyPress = false; cancelNextKeyPress = false; Event nativeEvent = (Event) event.getNativeEvent(); if (!nativeEvent.isCancelled()) { handleKeyRelease(nativeEvent); } }
@Override public void onKeyPress(KeyPressEvent event) { Event nativeEvent = (Event) event.getNativeEvent(); if (!ignoreNextKeyPress) { if (!nativeEvent.isCancelled()) { handleRepeatableKey(nativeEvent); } } else if (cancelNextKeyPress) { nativeEvent.xPreventDefault(); } ignoreNextKeyPress = false; cancelNextKeyPress = false; }
/** * Called when a KeyDown event is triggered inside the rich text area. * * @param event the native event that was fired */ protected void onKeyDown(Event event) { if (event == null || event.isCancelled()) { return; } switch (event.getKeyCode()) { case KeyCodes.KEY_DOWN: onDownArrow(event); break; case KeyCodes.KEY_UP: onUpArrow(event); break; default: break; } }
/** * Called by the underlying rich text are when user actions trigger browser events, after all the * registered listeners have been notified. * * @param event the native event that was fired * @see RichTextArea#onBrowserEvent(com.google.gwt.user.client.Event) * @see RichTextArea#getCurrentEvent() */ public void onBrowserEvent(Event event) { if (event == null || event.isCancelled()) { return; } switch (event.getTypeInt()) { case Event.ONKEYDOWN: onKeyDown(event); break; case Event.ONKEYPRESS: onKeyPress(event); break; case Event.ONLOAD: onLoad(event); break; default: break; } }
@Override protected void onKeyDown(Event event) { if (event == null || event.isCancelled()) { return; } switch (event.getKeyCode()) { case KeyCodes.KEY_TAB: // IE moves the focus when Tab key is down and thus the key press event doesn't get fired. // If we block // the key down event then IE doesn't fire key press. We are forced to apply out custom // behavior for tab // key now, on key down, and not later, on key press. onTab(event); break; default: super.onKeyDown(event); break; } }