Java Code Examples for com.google.gwt.event.dom.client.KeyPressEvent
The following examples show how to use
com.google.gwt.event.dom.client.KeyPressEvent. These examples are extracted from open source projects.
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 Project: swellrt Source File: FocusManager.java License: Apache License 2.0 | 6 votes |
/** * Installs a key handler for key events on this window. * * @param handler handler to receive key events. */ static void install(KeySignalHandler handler) { // // NOTE: There are three potential candidate elements for sinking keyboard // events: the window, the document, and the document body. IE7 does not // fire events on the window element, and GWT's RootPanel is already a // listener on the body, leaving the document as the only cross-browser // whole-window event-sinking 'element'. // DocumentPanel panel = new DocumentPanel(handler); panel.setElement(Document.get().<Element>cast()); panel.addDomHandler(panel, KeyDownEvent.getType()); panel.addDomHandler(panel, KeyPressEvent.getType()); panel.addDomHandler(panel, KeyUpEvent.getType()); RootPanel.detachOnWindowClose(panel); panel.onAttach(); }
Example 2
Source Project: putnami-web-toolkit Source File: AddressBookView.java License: GNU Lesser General Public License v3.0 | 6 votes |
@UiHandler("searchBox") void onSearchBox(KeyPressEvent event) { final InputText source = (InputText) event.getSource(); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { String query = source.flush(); if (query == null || query.length() == 0) { displayList(displayedList); } else { final String queryToCompare = query.toLowerCase().trim(); Iterable<Contact> filteredIteable = Iterables.filter(displayedList, new Predicate<Contact>() { @Override public boolean apply(Contact contact) { return contact.getName() != null && contact.getName().toLowerCase().contains(queryToCompare); } }); displayList(Lists.newArrayList(filteredIteable)); } } }); }
Example 3
Source Project: putnami-web-toolkit Source File: MaskValueBoxHelper.java License: GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onKeyPress(KeyPressEvent event) { int i = helpers.indexOf(currentHelper); if (currentHelper != null) { if (currentHelper.handleKeyPress(event)) { refreshValueBox(); event.preventDefault(); } else if (1 + i < helpers.size()) { if (!helpers.get(1 + i).handleKeyPress(event) && 2 + i < helpers.size()) { focus(i + 1); helpers.get(2 + i).handleKeyPress(event); } else { focus(i + 1); } } else { event.preventDefault(); } } }
Example 4
Source Project: putnami-web-toolkit Source File: AddressBookPage.java License: GNU Lesser General Public License v3.0 | 6 votes |
@UiHandler("searchBox") void onSearchBox(KeyPressEvent event) { final InputText source = (InputText) event.getSource(); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { String query = source.flush(); if (query == null || query.length() == 0) { AddressBookPage.this.displayList(AddressBookPage.this.displayedList); } else { final String queryToCompare = query.toLowerCase().trim(); Iterable<Contact> filteredIteable = Iterables.filter(AddressBookPage.this.displayedList, new Predicate<Contact>() { @Override public boolean apply(Contact contact) { return contact.getName() != null && contact.getName().toLowerCase().contains(queryToCompare); } }); AddressBookPage.this.displayList(Lists.newArrayList(filteredIteable)); } } }); }
Example 5
Source Project: incubator-retired-wave Source File: FocusManager.java License: Apache License 2.0 | 6 votes |
/** * Installs a key handler for key events on this window. * * @param handler handler to receive key events. */ static void install(KeySignalHandler handler) { // // NOTE: There are three potential candidate elements for sinking keyboard // events: the window, the document, and the document body. IE7 does not // fire events on the window element, and GWT's RootPanel is already a // listener on the body, leaving the document as the only cross-browser // whole-window event-sinking 'element'. // DocumentPanel panel = new DocumentPanel(handler); panel.setElement(Document.get().<Element>cast()); panel.addDomHandler(panel, KeyDownEvent.getType()); panel.addDomHandler(panel, KeyPressEvent.getType()); panel.addDomHandler(panel, KeyUpEvent.getType()); RootPanel.detachOnWindowClose(panel); panel.onAttach(); }
Example 6
Source Project: appinventor-extensions Source File: YoungAndroidPalettePanel.java License: Apache License 2.0 | 5 votes |
@Override public void onKeyPress(KeyPressEvent event) { switch (event.getCharCode()) { case KeyCodes.KEY_END: case KeyCodes.KEY_DELETE: case KeyCodes.KEY_BACKSPACE: doSearch(); break; } }
Example 7
Source Project: sc2gears Source File: ClientUtils.java License: Apache License 2.0 | 5 votes |
/** * Adds a {@link KeyPressHandler} to the specified widget which calls {@link Button#click()} on <code>targetButton</code> * when the Enter key is pressed. * @param widget widget to add the key handler to * @param targetButton target button to activate when the enter key is pressed */ public static void addEnterTarget( final HasKeyPressHandlers widget, final Button targetButton ) { widget.addKeyPressHandler( new KeyPressHandler() { @Override public void onKeyPress( final KeyPressEvent event ) { if ( event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER ) targetButton.click(); } } ); }
Example 8
Source Project: unitime Source File: NumberBox.java License: Apache License 2.0 | 5 votes |
public NumberBox() { setStyleName("gwt-SuggestBox"); setWidth("100px"); getElement().getStyle().setTextAlign(TextAlign.RIGHT); addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { if (!isEnabled() || isReadOnly()) return; int keyCode = event.getNativeEvent().getKeyCode(); switch (keyCode) { case KeyCodes.KEY_BACKSPACE: case KeyCodes.KEY_DELETE: case KeyCodes.KEY_ESCAPE: case KeyCodes.KEY_RIGHT: case KeyCodes.KEY_LEFT: case KeyCodes.KEY_TAB: return; } if (isDecimal() && event.getCharCode() == '.' && !getValue().contains(".")) return; if (isNegative() && event.getCharCode() == '-' && !getValue().contains("-") && (getCursorPos() == 0 || getSelectionLength() == getValue().length())) return; if (Character.isDigit(event.getCharCode())) return; cancelKey( ); } } ); }
Example 9
Source Project: dashbuilder Source File: NavRootNodeEditorView.java License: 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 Project: dashbuilder Source File: NavItemDefaultEditorView.java License: 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 11
Source Project: putnami-web-toolkit Source File: AbstractDropdown.java License: GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onKeyPress(KeyPressEvent event) { if (event.getCharCode() == KeyCodes.KEY_ENTER) { this.toggleOpen(); event.preventDefault(); event.stopPropagation(); } }
Example 12
Source Project: putnami-web-toolkit Source File: InputEmail.java License: GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onKeyPress(KeyPressEvent event) { boolean valid = false; char pressed = event.getCharCode(); for (char c : ALLOWED_CHARS) { if (c == pressed) { valid = true; break; } } if (!valid) { event.preventDefault(); event.stopPropagation(); } }
Example 13
Source Project: putnami-web-toolkit Source File: StaticStringTokenHelper.java License: GNU Lesser General Public License v3.0 | 5 votes |
@Override protected boolean handleKeyPress(KeyPressEvent event) { boolean b = handleKeyPress(event.getCharCode()); if (b) { event.preventDefault(); event.stopPropagation(); } return b; }
Example 14
Source Project: appinventor-extensions Source File: HandlerPanel.java License: Apache License 2.0 | 4 votes |
public HandlerRegistration addKeyPressHandler(KeyPressHandler handler) { return addDomHandler(handler, KeyPressEvent.getType()); }
Example 15
Source Project: swellrt Source File: FocusManager.java License: Apache License 2.0 | 4 votes |
@Override public void onKeyPress(KeyPressEvent event) { dispatch(event); }
Example 16
Source Project: putnami-web-toolkit Source File: AbstractInput.java License: GNU Lesser General Public License v3.0 | 4 votes |
@Override public com.google.gwt.event.shared.HandlerRegistration addKeyPressHandler(KeyPressHandler handler) { return this.addDomHandler(handler, KeyPressEvent.getType()); }
Example 17
Source Project: putnami-web-toolkit Source File: ListItem.java License: GNU Lesser General Public License v3.0 | 4 votes |
@Override public HandlerRegistration addKeyPressHandler(KeyPressHandler handler) { return this.addDomHandler(handler, KeyPressEvent.getType()); }
Example 18
Source Project: putnami-web-toolkit Source File: MaskValueBoxHelper.java License: GNU Lesser General Public License v3.0 | 4 votes |
protected boolean handleKeyPress(KeyPressEvent event) { return handleKeyPress(event.getCharCode()); }
Example 19
Source Project: putnami-web-toolkit Source File: Anchor.java License: GNU Lesser General Public License v3.0 | 4 votes |
@Override public HandlerRegistration addKeyPressHandler(KeyPressHandler handler) { return this.addDomHandler(handler, KeyPressEvent.getType()); }
Example 20
Source Project: incubator-retired-wave Source File: FocusManager.java License: Apache License 2.0 | 4 votes |
@Override public void onKeyPress(KeyPressEvent event) { dispatch(event); }