Java Code Examples for com.google.gwt.event.dom.client.KeyCodes#KEY_TAB
The following examples show how to use
com.google.gwt.event.dom.client.KeyCodes#KEY_TAB .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InputMultiSelect.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onBrowserEvent(Event event) { super.onBrowserEvent(event); boolean mustKillEvent = false; if (DOM.eventGetType(event) == Event.ONKEYDOWN) { switch (event.getKeyCode()) { case KeyCodes.KEY_ENTER: if (this.getDropdown().isOpen()) { ((MultiSelectionHandler) this.getSelectionHandler()).onEnterKeyDown(); mustKillEvent = true; } break; case KeyCodes.KEY_TAB: case KeyCodes.KEY_ESCAPE: this.getDropdown().close(); break; default: break; } } if (mustKillEvent) { event.preventDefault(); event.stopPropagation(); } }
Example 2
Source File: VContextMenu.java From cuba with Apache License 2.0 | 6 votes |
@Override public boolean handleNavigation(int keycode, boolean ctrl, boolean shift) { if (keycode == KeyCodes.KEY_TAB) { return true; } if (keycode == getNavigationLeftKey() && (getParentMenu() == null || getParentMenu().getParentMenu() == null)) { // do not close parent menu by left key return true; } if (keycode == getNavigationRightKey() && getSelected() != null && getSelected().getSubMenu() == null) { // do not close menu by right key if there is no submenu return true; } return super.handleNavigation(keycode, ctrl, shift); }
Example 3
Source File: InputSelect.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onBrowserEvent(Event event) { super.onBrowserEvent(event); boolean mustKillEvent = false; if (DOM.eventGetType(event) == Event.ONKEYDOWN) { switch (event.getKeyCode()) { case KeyCodes.KEY_TAB: case KeyCodes.KEY_ESCAPE: this.getDropdown().close(); break; default: break; } } if (mustKillEvent) { event.preventDefault(); event.stopPropagation(); } }
Example 4
Source File: CompositeFocusHelper.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onKeyDown(KeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_TAB) { Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { Element activeElement = FocusUtils.getActiveElement(); if (activeElement != null && !CompositeFocusHelper.this.isOrHasChildOfContainerOrPartner(activeElement)) { CompositeFocusHelper.this.blur(); } } }); } }
Example 5
Source File: TextPropertyEditorBase.java From appinventor-extensions with Apache License 2.0 | 5 votes |
private void handleKeyPress(char keyCode) { if (keyCode == KeyCodes.KEY_ENTER || keyCode == KeyCodes.KEY_TAB) { // Pressing <tab>, <enter> or <return> will surrender focus. textEdit.cancelKey(); textEdit.setFocus(false); } else if (!validateKeyCode(keyCode)) { textEdit.cancelKey(); } }
Example 6
Source File: UTCTimeBoxImplHtml4.java From gwt-traction with Apache License 2.0 | 5 votes |
@Override public void onKeyDown(KeyDownEvent event) { switch (event.getNativeKeyCode()) { case KeyCodes.KEY_UP: menu.adjustHighlight(-1); break; case KeyCodes.KEY_DOWN: menu.adjustHighlight(1); break; case KeyCodes.KEY_ENTER: case KeyCodes.KEY_TAB: // accept current value if (menu.isShowing()) { menu.acceptHighlighted(); hideMenu(); clearInvalidStyle(); } else { // added a sync here because this is when we // accept the value we've typed if we're typing in // a new value. syncValueToText(); validate(); } break; case KeyCodes.KEY_ESCAPE: validate(); hideMenu(); break; default: hideMenu(); clearInvalidStyle(); break; } }
Example 7
Source File: EditorEventHandler.java From swellrt with Apache License 2.0 | 5 votes |
/** * Parameterised to allow testing different browser/os permuations * @param event * @param isMac * @param quirksHasOldSchoolClipboardShortcuts */ @VisibleForTesting static boolean isAcceleratorInner(SignalEvent event, boolean isMac, boolean quirksHasOldSchoolClipboardShortcuts) { switch (event.getKeySignalType()) { case INPUT: // Alt on its own is a simple modifier, like shift, on OSX boolean maybeAltKey = !isMac && event.getAltKey(); // NOTE(user): Perhaps we should create a registry in // EditorEventSubHandler of non-metesque like command keys such as TAB. // For now TAB is our only special case, but we may need to allow // implementers to define arbitrary keys as accelerators. return event.getCtrlKey() || event.getMetaKey() || event.getKeyCode() == KeyCodes.KEY_TAB || maybeAltKey; case DELETE: if (quirksHasOldSchoolClipboardShortcuts && event.getKeyCode() == KeyCodes.KEY_DELETE && KeyModifier.SHIFT.check(event)) { // shift+delete on windows/linux is cut // (shift+insert and ctrl+insert are other clipboard alternatives, // but that's handled below). return true; } else { return false; } case NAVIGATION: // All navigation does not count return false; case NOEFFECT: // Random special keys like ESC, F7, TAB, INS, etc count return true; } throw new RuntimeException("Unknown KeySignal type"); }
Example 8
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 5 votes |
/** * Triggered when a key was depressed. * * @param event * The KeyUpEvent of the key depressed */ @Override public void onKeyUp(KeyUpEvent event) { debug("VComboBoxMultiselect: onKeyUp(" + event.getNativeKeyCode() + ")"); if (this.enabled && !this.readonly) { switch (event.getNativeKeyCode()) { case KeyCodes.KEY_ENTER: case KeyCodes.KEY_TAB: case KeyCodes.KEY_SHIFT: case KeyCodes.KEY_CTRL: case KeyCodes.KEY_ALT: case KeyCodes.KEY_DOWN: case KeyCodes.KEY_UP: case KeyCodes.KEY_PAGEDOWN: case KeyCodes.KEY_PAGEUP: case KeyCodes.KEY_ESCAPE: // NOP break; default: if (this.textInputEnabled) { // when filtering, we always want to see the results on the // first page first. filterOptions(0); } break; } } }
Example 9
Source File: CubaOptionGroupWidget.java From cuba with Apache License 2.0 | 5 votes |
@Override public void onKeyDown(KeyDownEvent event) { if ((!isEnabled() || isReadonly()) && event.getNativeKeyCode() != KeyCodes.KEY_TAB) { event.preventDefault(); } }
Example 10
Source File: EditorEventHandler.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
/** * Parameterised to allow testing different browser/os permuations * @param event * @param isMac * @param quirksHasOldSchoolClipboardShortcuts */ @VisibleForTesting static boolean isAcceleratorInner(SignalEvent event, boolean isMac, boolean quirksHasOldSchoolClipboardShortcuts) { switch (event.getKeySignalType()) { case INPUT: // Alt on its own is a simple modifier, like shift, on OSX boolean maybeAltKey = !isMac && event.getAltKey(); // NOTE(user): Perhaps we should create a registry in // EditorEventSubHandler of non-metesque like command keys such as TAB. // For now TAB is our only special case, but we may need to allow // implementers to define arbitrary keys as accelerators. return event.getCtrlKey() || event.getMetaKey() || event.getKeyCode() == KeyCodes.KEY_TAB || maybeAltKey; case DELETE: if (quirksHasOldSchoolClipboardShortcuts && event.getKeyCode() == KeyCodes.KEY_DELETE && KeyModifier.SHIFT.check(event)) { // shift+delete on windows/linux is cut // (shift+insert and ctrl+insert are other clipboard alternatives, // but that's handled below). return true; } else { return false; } case NAVIGATION: // All navigation does not count return false; case NOEFFECT: // Random special keys like ESC, F7, TAB, INS, etc count return true; } throw new RuntimeException("Unknown KeySignal type"); }
Example 11
Source File: CubaCheckBoxWidget.java From cuba with Apache License 2.0 | 5 votes |
@Override public void onKeyDown(KeyDownEvent event) { if ((!isEnabled() || isReadOnly()) && event.getNativeKeyCode() != KeyCodes.KEY_TAB) { event.preventDefault(); } }
Example 12
Source File: CubaRadioButtonGroupWidget.java From cuba with Apache License 2.0 | 5 votes |
@Override public void onKeyDown(KeyDownEvent event) { if ((!isEnabled() || isReadonly()) && event.getNativeKeyCode() != KeyCodes.KEY_TAB) { event.preventDefault(); } }
Example 13
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 5 votes |
/** * Triggered when a key was depressed. * * @param event * The KeyUpEvent of the key depressed */ @Override public void onKeyUp(KeyUpEvent event) { debug("VComboBoxMultiselect: onKeyUp(" + event.getNativeKeyCode() + ")"); if (this.enabled && !this.readonly) { switch (event.getNativeKeyCode()) { case KeyCodes.KEY_ENTER: case KeyCodes.KEY_TAB: case KeyCodes.KEY_SHIFT: case KeyCodes.KEY_CTRL: case KeyCodes.KEY_ALT: case KeyCodes.KEY_DOWN: case KeyCodes.KEY_UP: case KeyCodes.KEY_PAGEDOWN: case KeyCodes.KEY_PAGEUP: case KeyCodes.KEY_ESCAPE: // NOP break; default: if (this.textInputEnabled) { // when filtering, we always want to see the results on the // first page first. filterOptions(0); } break; } } }
Example 14
Source File: YoungAndroidDefaultURLPropertyEditor.java From appinventor-extensions with Apache License 2.0 | 5 votes |
private void handleKeyPress(char keyCode) { if (keyCode == KeyCodes.KEY_ENTER || keyCode == KeyCodes.KEY_TAB) { // Pressing <tab>, <enter> or <return> will surrender focus. urlField.cancelKey(); urlField.setFocus(false); } else if (!validateKeyCode(keyCode)) { urlField.cancelKey(); } }
Example 15
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 4 votes |
/** * Triggered when a key was pressed in the suggestion popup. * * @param event * The KeyDownEvent of the key */ private void popupKeyDown(KeyDownEvent event) { debug("VComboBoxMultiselect: popupKeyDown(" + event.getNativeKeyCode() + ")"); // Propagation of handled events is stopped so other handlers such as // shortcut key handlers do not also handle the same events. switch (event.getNativeKeyCode()) { case KeyCodes.KEY_DOWN: this.suggestionPopup.selectNextItem(); DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); event.stopPropagation(); break; case KeyCodes.KEY_UP: this.suggestionPopup.selectPrevItem(); DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); event.stopPropagation(); break; case KeyCodes.KEY_PAGEDOWN: selectNextPage(); event.stopPropagation(); break; case KeyCodes.KEY_PAGEUP: selectPrevPage(); event.stopPropagation(); break; case KeyCodes.KEY_ESCAPE: reset(); DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); event.stopPropagation(); break; case KeyCodes.KEY_TAB: case KeyCodes.KEY_ENTER: // queue this, may be cancelled by selection int selectedIndex = this.suggestionPopup.menu.getSelectedIndex(); if (!this.allowNewItems && selectedIndex != -1) { debug("index before: " + selectedIndex); if (this.showClearButton) { selectedIndex = selectedIndex - 1; } if (this.showSelectAllButton) { selectedIndex = selectedIndex - 1; } debug("index after: " + selectedIndex); if (selectedIndex == -2) { this.clearCmd.execute(); } else if (selectedIndex == -1) { if (this.showSelectAllButton) { this.selectAllCmd.execute(); } else { this.clearCmd.execute(); } } debug("entered suggestion: " + this.currentSuggestions.get(selectedIndex).caption); onSuggestionSelected(this.currentSuggestions.get(selectedIndex)); } else { this.dataReceivedHandler.reactOnInputWhenReady(this.tb.getText()); } event.stopPropagation(); break; } }
Example 16
Source File: MaskValueBoxHelper.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 4 votes |
public void onKeyDown(KeyDownEvent event) { this.keyDown = event.getNativeKeyCode(); boolean preventDefault = false; switch (event.getNativeKeyCode()) { case KeyCodes.KEY_DELETE: case KeyCodes.KEY_BACKSPACE: if (this.token != null) { this.reset(); this.maskHelper.refreshValueBox(); event.preventDefault(); } break; case KeyCodes.KEY_DOWN: case KeyCodes.KEY_UP: event.preventDefault(); break; case KeyCodes.KEY_LEFT: preventDefault = this.maskHelper.focusPrevious(); break; case KeyCodes.KEY_RIGHT: preventDefault = this.maskHelper.focusNext(); break; case KeyCodes.KEY_TAB: if (event.isShiftKeyDown()) { preventDefault = this.maskHelper.focusPrevious(); } else { preventDefault = this.maskHelper.focusNext(); } break; default: break; } if (preventDefault) { event.preventDefault(); } if (this.handleKeyDown(this.keyDown)) { this.maskHelper.refreshValueBox(); this.schedule(this.maskHelper.initialDelayMilis); } }
Example 17
Source File: EditorImpl.java From incubator-retired-wave with Apache License 2.0 | 4 votes |
@Override public boolean handleBlockLevelCommands(EditorEvent event, ContentRange selection) { Point<ContentNode> start = selection.getFirst(); Point<ContentNode> end = selection.getSecond(); // Shonky key combos until toolbar if (KeyModifier.CTRL.check(event)) { int startLoc = mapper().getLocation(start); int endLoc = mapper().getLocation(end); int num = event.getKeyCode() - '1' + 1; if (num >= 1 && num <= 6) { if (num == 5) { final String listStyle; Line l = Paragraph.getFirstLine(mapper(), mapper().getLocation(start)); if (Paragraph.LIST_TYPE.equals(l.getAttribute(Paragraph.SUBTYPE_ATTR)) && !Paragraph.LIST_STYLE_DECIMAL.equals(l.getAttribute(Paragraph.LIST_STYLE_ATTR))) { listStyle = Paragraph.LIST_STYLE_DECIMAL; } else { listStyle = null; // default style } Paragraph.apply(mapper(), startLoc, endLoc, Paragraph.listStyle(listStyle), true); } else { final String type; if (num == 6) { type = null; } else { type = "h" + num; } Paragraph.toggle(mapper(), startLoc, endLoc, Paragraph.regularStyle(type)); } settings.getInstrumentor().record(Action.SHORTCUT_HEADINGSTYLE); return true; } else if (num == 7) { Paragraph.apply(mapper(), startLoc, endLoc, Paragraph.Alignment.LEFT, true); Paragraph.apply(mapper(), startLoc, endLoc, Paragraph.Direction.LTR, true); settings.getInstrumentor().record(Action.SHORTCUT_ALIGNMENT); return true; } else if (num == 8) { Paragraph.apply(mapper(), startLoc, endLoc, Paragraph.Alignment.RIGHT, true); Paragraph.apply(mapper(), startLoc, endLoc, Paragraph.Direction.RTL, true); settings.getInstrumentor().record(Action.SHORTCUT_ALIGNMENT); return true; } } else if (event.getKeyCode() == KeyCodes.KEY_TAB) { handleTab(start, end, event.getShiftKey()); return true; } return false; }
Example 18
Source File: EditorImpl.java From swellrt with Apache License 2.0 | 4 votes |
@Override public boolean handleBlockLevelCommands(EditorEvent event, ContentRange selection) { Point<ContentNode> start = selection.getFirst(); Point<ContentNode> end = selection.getSecond(); // Shonky key combos until toolbar if (KeyModifier.CTRL.check(event)) { int startLoc = mapper().getLocation(start); int endLoc = mapper().getLocation(end); int num = event.getKeyCode() - '1' + 1; if (num >= 1 && num <= 6) { if (num == 5) { final String listStyle; Line l = Paragraph.getFirstLine(mapper(), mapper().getLocation(start)); if (Paragraph.LIST_TYPE.equals(l.getAttribute(Paragraph.SUBTYPE_ATTR)) && !Paragraph.LIST_STYLE_DECIMAL.equals(l.getAttribute(Paragraph.LIST_STYLE_ATTR))) { listStyle = Paragraph.LIST_STYLE_DECIMAL; } else { listStyle = null; // default style } Paragraph.apply(mapper(), startLoc, endLoc, Paragraph.listStyle(listStyle), true); } else { final String type; if (num == 6) { type = null; } else { type = "h" + num; } Paragraph.toggle(mapper(), startLoc, endLoc, Paragraph.regularStyle(type)); } settings.getInstrumentor().record(Action.SHORTCUT_HEADINGSTYLE); return true; } else if (num == 7) { Paragraph.apply(mapper(), startLoc, endLoc, Paragraph.Alignment.LEFT, true); Paragraph.apply(mapper(), startLoc, endLoc, Paragraph.Direction.LTR, true); settings.getInstrumentor().record(Action.SHORTCUT_ALIGNMENT); return true; } else if (num == 8) { Paragraph.apply(mapper(), startLoc, endLoc, Paragraph.Alignment.RIGHT, true); Paragraph.apply(mapper(), startLoc, endLoc, Paragraph.Direction.RTL, true); settings.getInstrumentor().record(Action.SHORTCUT_ALIGNMENT); return true; } } else if (event.getKeyCode() == KeyCodes.KEY_TAB) { handleTab(start, end, event.getShiftKey()); return true; } return false; }
Example 19
Source File: CubaSearchSelectWidget.java From cuba with Apache License 2.0 | 4 votes |
@Override protected void popupKeyDown(KeyDownEvent event) { // Propagation of handled events is stopped so other handlers such as // shortcut key handlers do not also handle the same events. switch (event.getNativeKeyCode()) { case KeyCodes.KEY_DOWN: keyboardNavigation = true; suggestionPopup.selectNextItem(); suggestionPopup.menu.selectItem(suggestionPopup.menu .getSelectedItem()); DOM.eventGetCurrentEvent().preventDefault(); event.stopPropagation(); break; case KeyCodes.KEY_UP: keyboardNavigation = true; suggestionPopup.selectPrevItem(); suggestionPopup.menu.selectItem(suggestionPopup.menu .getSelectedItem()); DOM.eventGetCurrentEvent().preventDefault(); event.stopPropagation(); break; case KeyCodes.KEY_PAGEDOWN: keyboardNavigation = false; if (hasNextPage()) { filterOptions(currentPage + 1, lastFilter); } event.stopPropagation(); break; case KeyCodes.KEY_PAGEUP: keyboardNavigation = false; if (currentPage > 0) { filterOptions(currentPage - 1, lastFilter); } event.stopPropagation(); break; case KeyCodes.KEY_ESCAPE: keyboardNavigation = false; reset(); event.stopPropagation(); break; case KeyCodes.KEY_TAB: case KeyCodes.KEY_ENTER: int selectedIndex = suggestionPopup.menu.getSelectedIndex(); currentSuggestion = currentSuggestions.get(selectedIndex); if (currentSuggestion != null && currentSuggestion.getReplacementString().equals(tb.getText())) { this.preventFilterAfterSelect = true; onSuggestionSelected(currentSuggestion); } keyboardNavigation = false; event.stopPropagation(); break; } }
Example 20
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 4 votes |
/** * Triggered when a key was pressed in the suggestion popup. * * @param event * The KeyDownEvent of the key */ private void popupKeyDown(KeyDownEvent event) { debug("VComboBoxMultiselect: popupKeyDown(" + event.getNativeKeyCode() + ")"); // Propagation of handled events is stopped so other handlers such as // shortcut key handlers do not also handle the same events. switch (event.getNativeKeyCode()) { case KeyCodes.KEY_DOWN: this.suggestionPopup.selectNextItem(); DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); event.stopPropagation(); break; case KeyCodes.KEY_UP: this.suggestionPopup.selectPrevItem(); DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); event.stopPropagation(); break; case KeyCodes.KEY_PAGEDOWN: selectNextPage(); event.stopPropagation(); break; case KeyCodes.KEY_PAGEUP: selectPrevPage(); event.stopPropagation(); break; case KeyCodes.KEY_ESCAPE: reset(); DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); event.stopPropagation(); break; case KeyCodes.KEY_TAB: case KeyCodes.KEY_ENTER: // queue this, may be cancelled by selection int selectedIndex = this.suggestionPopup.menu.getSelectedIndex(); if (!this.allowNewItems && selectedIndex != -1) { debug("index before: " + selectedIndex); if (this.showClearButton) { selectedIndex = selectedIndex - 1; } if (this.showSelectAllButton) { selectedIndex = selectedIndex - 1; } debug("index after: " + selectedIndex); if (selectedIndex == -2) { this.clearCmd.execute(); } else if (selectedIndex == -1) { if (this.showSelectAllButton) { this.selectAllCmd.execute(); } else { this.clearCmd.execute(); } } debug("entered suggestion: " + this.currentSuggestions.get(selectedIndex).caption); onSuggestionSelected(this.currentSuggestions.get(selectedIndex)); } else { this.dataReceivedHandler.reactOnInputWhenReady(this.tb.getText()); } event.stopPropagation(); break; } }