Java Code Examples for com.google.gwt.event.dom.client.KeyCodes#KEY_ENTER
The following examples show how to use
com.google.gwt.event.dom.client.KeyCodes#KEY_ENTER .
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: AutoCompleteTextFieldConnector.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
private void handlePanelEventDelegation(final KeyUpEvent event) { switch (event.getNativeKeyCode()) { case KeyCodes.KEY_DOWN: arrowKeyDown(event); break; case KeyCodes.KEY_UP: arrorKeyUp(event); break; case KeyCodes.KEY_ESCAPE: escapeKey(); break; case KeyCodes.KEY_ENTER: enterKey(); break; default: doAskForSuggestion(); } }
Example 2
Source File: AriaLink.java From core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void onBrowserEvent(Event event) { int type = DOM.eventGetType(event); switch (type) { case Event.ONKEYDOWN: if(event.getKeyCode()== KeyCodes.KEY_ENTER) { if(handler!=null) handler.onClick(null); event.stopPropagation(); } break; default: return; } }
Example 3
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 4
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 5
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 5 votes |
@Override public void onKeyDown(KeyDownEvent event) { if (this.enabled && !this.readonly) { int keyCode = event.getNativeKeyCode(); debug("VComboBoxMultiselect: key down: " + keyCode); if (this.dataReceivedHandler.isWaitingForFilteringResponse() && navigationKeyCodes.contains(keyCode) && (!this.allowNewItems || keyCode != KeyCodes.KEY_ENTER)) { /* * Keyboard navigation events should not be handled while we are * waiting for a response. This avoids flickering, disappearing * items, wrongly interpreted responses and more. */ debug("Ignoring " + keyCode + " because we are waiting for a filtering response"); DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); event.stopPropagation(); return; } if (this.suggestionPopup.isAttached()) { debug("Keycode " + keyCode + " target is popup"); popupKeyDown(event); } else { debug("Keycode " + keyCode + " target is text field"); inputFieldKeyDown(event); } } }
Example 6
Source File: SuggestPopup.java From cuba with Apache License 2.0 | 5 votes |
@Override public void onKeyDown(KeyDownEvent event) { int keyCode = event.getNativeKeyCode(); if (keyCode == KeyCodes.KEY_ENTER && choiceList.getSelectedIndex() != -1) { event.preventDefault(); event.stopPropagation(); select(); } else if (keyCode == KeyCodes.KEY_ESCAPE) { event.preventDefault(); close(); } }
Example 7
Source File: CubaSourceCodeEditorWidget.java From cuba with Apache License 2.0 | 5 votes |
@Override public void onBrowserEvent(Event event) { int type = DOM.eventGetType(event); if (type == Event.ONKEYDOWN && event.getKeyCode() == KeyCodes.KEY_ENTER && !event.getAltKey() && !event.getShiftKey() && !event.getCtrlKey()) { event.stopPropagation(); return; } super.onBrowserEvent(event); }
Example 8
Source File: GeoDataImportDialog.java From geowe-core with GNU General Public License v3.0 | 5 votes |
private void addKeyShortcuts() { KeyShortcutHandler keyShortcut = new KeyShortcutHandler( getButton(PredefinedButton.OK), KeyCodes.KEY_ENTER); layerName.addKeyDownHandler(keyShortcut); projectionName.addKeyDownHandler(keyShortcut); vectorFormatCombo.addKeyDownHandler(keyShortcut); geoDataTextArea.addKeyDownHandler(keyShortcut); }
Example 9
Source File: NavItemDefaultEditorView.java From dashbuilder with Apache License 2.0 | 5 votes |
@EventHandler("itemNameInput") public void onItemNameChanged(KeyPressEvent keyEvent) { if (keyEvent.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) { presenter.onChangesOk(); } else { presenter.onItemNameChanged(); } }
Example 10
Source File: ApplicationRootView.java From bitcoin-transaction-explorer with MIT License | 5 votes |
@UiHandler("lookupField") public void onLookupKeyUp(final KeyUpEvent event) { if (event.getNativeKeyCode() != KeyCodes.KEY_ENTER) { return; } final ApplicationPlace place = PlaceTokenParseUtil.parseToken(lookupField.getText()); if (place == null) { // Do something, like show a mild error. return; } placeController.goTo(place); }
Example 11
Source File: CoordinateGeolocationDialog.java From geowe-core with GNU General Public License v3.0 | 5 votes |
private void addKeyShortcuts() { final KeyShortcutHandler keyShortcut = new KeyShortcutHandler( getButton(PredefinedButton.OK), KeyCodes.KEY_ENTER); latitudTextField.addKeyDownHandler(keyShortcut); longitudTextField.addKeyDownHandler(keyShortcut); }
Example 12
Source File: NavRootNodeEditorView.java From dashbuilder with Apache License 2.0 | 5 votes |
@EventHandler("itemNameInput") public void onItemNameChanged(KeyPressEvent keyEvent) { if (keyEvent.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) { presenter.onChangesOk(); } else { presenter.onItemNameChanged(); } }
Example 13
Source File: MockComponent.java From appinventor-extensions with Apache License 2.0 | 5 votes |
@Override protected void onPreviewNativeEvent(NativePreviewEvent event) { super.onPreviewNativeEvent(event); switch (event.getTypeInt()) { case Event.ONKEYDOWN: if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ESCAPE) { hide(); } else if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) { hide(); MockComponent.this.delete(); } break; } }
Example 14
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 15
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 16
Source File: CubaPopupButtonWidget.java From cuba with Apache License 2.0 | 4 votes |
@Override protected boolean handleKeyboardEvents(Event event) { int type = DOM.eventGetType(event); // Synthesize clicks based on keyboard events AFTER the normal key // handling. if ((event.getTypeInt() & Event.KEYEVENTS) != 0) { switch (type) { case Event.ONKEYDOWN: // Button should not react on shortcuts with ENTER and SPACE if (isShortcut(event) && (event.getKeyCode() == KeyCodes.KEY_ENTER || event.getKeyCode() == KeyCodes.KEY_SPACE)) { return true; } // Stop propagation when the user starts pressing a button that // we are handling to prevent actions from getting triggered if (event.getKeyCode() == KeyCodes.KEY_SPACE) { isFocusing = true; event.preventDefault(); event.stopPropagation(); return true; } else if (event.getKeyCode() == KeyCodes.KEY_ENTER) { isFocusing = true; event.stopPropagation(); return true; } else if (event.getKeyCode() == KeyCodes.KEY_DOWN) { isFocusing = true; event.stopPropagation(); } break; // CAUTION IE sometimes does not generate ONKEYPRESS for ENTER, so we override default Vaadin behavior case Event.ONKEYUP: if (isFocusing) { if (event.getKeyCode() == KeyCodes.KEY_SPACE) { isFocusing = false; onClick(); event.stopPropagation(); event.preventDefault(); return true; } else if (event.getKeyCode() == KeyCodes.KEY_ENTER) { isFocusing = false; onClick(); event.stopPropagation(); event.preventDefault(); return true; } else if (event.getKeyCode() == KeyCodes.KEY_DOWN) { isFocusing = false; onClick(); event.stopPropagation(); event.preventDefault(); return true; } } else if (isShortcut(event) && (event.getKeyCode() == KeyCodes.KEY_ENTER || event.getKeyCode() == KeyCodes.KEY_SPACE)) { return true; } break; case Event.ONKEYPRESS: { // Button should not react on shortcuts with ENTER and SPACE if (isShortcut(event) && (event.getKeyCode() == KeyCodes.KEY_ENTER || event.getKeyCode() == KeyCodes.KEY_SPACE)) { return true; } } } } return false; }
Example 17
Source File: SuggestionsContainer.java From cuba with Apache License 2.0 | 4 votes |
@Override public void onBrowserEvent(Event event) { if (getElement() == DOM.eventGetTarget(event)) { return; } SuggestionItem item = findItem(DOM.eventGetTarget(event)); switch (DOM.eventGetType(event)) { case Event.ONMOUSEDOWN: { if (BrowserInfo.get().isIE()) { suggestionFieldWidget.iePreventBlur = true; } break; } case Event.ONCLICK: { if (event.getButton() == NativeEvent.BUTTON_LEFT) { performItemCommand(item); } break; } case Event.ONMOUSEOVER: { if (item != null) { selectItem(item); } break; } case Event.ONKEYDOWN: { int keyCode = KeyCodes.maybeSwapArrowKeysForRtl( event.getKeyCode(), LocaleInfo.getCurrentLocale().isRTL() ); switch (keyCode) { case KeyCodes.KEY_UP: selectPrevItem(); preventEvent(event); break; case KeyCodes.KEY_DOWN: selectNextItem(); preventEvent(event); break; case KeyCodes.KEY_ESCAPE: selectItem(null); preventEvent(event); break; case KeyCodes.KEY_TAB: selectItem(null); break; case KeyCodes.KEY_ENTER: performItemCommand(item); preventEvent(event); break; } break; } } super.onBrowserEvent(event); }
Example 18
Source File: CubaButtonWidget.java From cuba with Apache License 2.0 | 4 votes |
@Override protected boolean handleKeyboardEvents(Event event) { int type = DOM.eventGetType(event); // Synthesize clicks based on keyboard events AFTER the normal key // handling. if ((event.getTypeInt() & Event.KEYEVENTS) != 0) { switch (type) { case Event.ONKEYDOWN: // Button should not react on shortcuts with ENTER and SPACE if (isShortcut(event) && (event.getKeyCode() == KeyCodes.KEY_ENTER || event.getKeyCode() == KeyCodes.KEY_SPACE)) { return true; } // Stop propagation when the user starts pressing a button that // we are handling to prevent actions from getting triggered if (event.getKeyCode() == KeyCodes.KEY_SPACE) { isFocusing = true; event.preventDefault(); event.stopPropagation(); return true; } else if (event.getKeyCode() == KeyCodes.KEY_ENTER) { isFocusing = true; event.preventDefault(); event.stopPropagation(); return true; } break; // CAUTION IE sometimes does not generate ONKEYPRESS for ENTER, so we override default Vaadin behavior case Event.ONKEYUP: if (isFocusing) { if (event.getKeyCode() == KeyCodes.KEY_SPACE) { isFocusing = false; onClick(); event.stopPropagation(); event.preventDefault(); return true; } else if (event.getKeyCode() == KeyCodes.KEY_ENTER) { isFocusing = false; onClick(); event.stopPropagation(); event.preventDefault(); return true; } } else if (isShortcut(event) && (event.getKeyCode() == KeyCodes.KEY_ENTER || event.getKeyCode() == KeyCodes.KEY_SPACE)) { return true; } break; case Event.ONKEYPRESS: { // Button should not react on shortcuts with ENTER and SPACE if (isShortcut(event) && (event.getKeyCode() == KeyCodes.KEY_ENTER || event.getKeyCode() == KeyCodes.KEY_SPACE)) { return true; } } } } return false; }
Example 19
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 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; } }