List of usage examples for com.google.gwt.user.client.ui KeyboardListener KEY_TAB
int KEY_TAB
To view the source code for com.google.gwt.user.client.ui KeyboardListener KEY_TAB.
Click Source Link
From source file:com.audata.client.widgets.NumericTextBox.java
License:Open Source License
public void onKeyDown(Widget sender, char keyCode, int modifiers) { String newChar = Character.toString(keyCode); switch (keyCode) { case (KeyboardListener.KEY_BACKSPACE): case (KeyboardListener.KEY_DELETE): case (KeyboardListener.KEY_DOWN): case (KeyboardListener.KEY_END): case (KeyboardListener.KEY_ENTER): case (KeyboardListener.KEY_ESCAPE): case (KeyboardListener.KEY_HOME): case (KeyboardListener.KEY_LEFT): case (KeyboardListener.KEY_PAGEUP): case (KeyboardListener.KEY_PAGEDOWN): case (KeyboardListener.KEY_RIGHT): case (KeyboardListener.KEY_SHIFT): case (KeyboardListener.KEY_TAB): case (KeyboardListener.KEY_UP): break;// ww w .j a v a2 s.co m default: try { new Double(newChar); } catch (NumberFormatException nfe) { this.cancelKey(); } } }
From source file:custgwttbl.client.CustGwtTable.java
License:Apache License
private void editCell(final int row, final int col, Widget widget) { stage = "Editing cell for Row:" + row + " Column:" + col; try {/*from www . j av a2 s . c o m*/ CustGwtItemBean ib = (CustGwtItemBean) this.vItemBeanList.get(col); final CustGwtItem tableCell = ib.getEditableComponent(); if (tableCell == null) { return; } String currText = ((CustGwtItem) widget).getText().trim(); grid.setWidget(row, col, tableCell); tableCell.setFocus(true); tableCell.setText(currText); tableCell.addKeyboardListener(new KeyboardListener() { public void onKeyDown(Widget sender, char keyCode, int modifiers) { } public void onKeyPress(Widget sender, char keyCode, int modifiers) { } public void onKeyUp(Widget sender, char keyCode, int modifiers) { switch (keyCode) { case KeyboardListener.KEY_ENTER: { updateRecord(row, col); break; } case KeyboardListener.KEY_TAB: { updateRecord(row, col); break; } } } }); tableCell.addFocusListener(new FocusListener() { public void onFocus(Widget sender) { } public void onLostFocus(Widget sender) { updateRecord(row, col); } }); } catch (Exception excep) { CustGwtUtil.showAlertOnError(excep, stage); } }
From source file:edu.purdue.pivot.skwiki.client.sketch.colorpicker.ColorPicker.java
License:Artistic License
/** * Fired when a keyboard action generates a character. This occurs after onKeyDown and onKeyUp are fired for the physical key that was pressed. * * It should be noted that many browsers do not generate keypress events for non-printing keyCode values, such as KEY_ENTER or arrow keys. These keyCodes can be reliably captured either with onKeyDown(Widget, char, int) or onKeyUp(Widget, char, int). * * Subclasses that override this method must call <tt>super.onKeyPress(sender, keyCode, modifiers)</tt> to ensure that the Widget recieves its events. * @param sender the widget that was focused when the event occurred. * @param keyCode the Unicode character that was generated by the keyboard action. * @param modifiers the modifier keys pressed at when the event occurred. This value is a combination of the bits defined by MODIFIER_SHIFT, MODIFIER_CTRL, and MODIFIER_ALT. * @see com.google.gwt.user.client.ui.KeyboardListener *///from w w w .ja va2 s . c om @Override public void onKeyPress(Widget sender, char keyCode, int modifiers) { if (sender == tbHexColor) { // Disallow non-hex in hexadecimal boxes if ((!Character.isDigit(keyCode)) && (keyCode != 'A') && (keyCode != 'a') && (keyCode != 'B') && (keyCode != 'b') && (keyCode != 'C') && (keyCode != 'c') && (keyCode != 'D') && (keyCode != 'd') && (keyCode != 'E') && (keyCode != 'e') && (keyCode != 'F') && (keyCode != 'f') && (keyCode != (char) KeyboardListener.KEY_TAB) && (keyCode != (char) KeyboardListener.KEY_BACKSPACE) && (keyCode != (char) KeyboardListener.KEY_DELETE) && (keyCode != (char) KeyboardListener.KEY_ENTER) && (keyCode != (char) KeyboardListener.KEY_HOME) && (keyCode != (char) KeyboardListener.KEY_END) && (keyCode != (char) KeyboardListener.KEY_LEFT) && (keyCode != (char) KeyboardListener.KEY_UP) && (keyCode != (char) KeyboardListener.KEY_RIGHT) && (keyCode != (char) KeyboardListener.KEY_DOWN)) { ((TextBox) sender).cancelKey(); } } else { // Disallow non-numerics in numeric boxes if ((!Character.isDigit(keyCode)) && (keyCode != (char) KeyboardListener.KEY_TAB) && (keyCode != (char) KeyboardListener.KEY_BACKSPACE) && (keyCode != (char) KeyboardListener.KEY_DELETE) && (keyCode != (char) KeyboardListener.KEY_ENTER) && (keyCode != (char) KeyboardListener.KEY_HOME) && (keyCode != (char) KeyboardListener.KEY_END) && (keyCode != (char) KeyboardListener.KEY_LEFT) && (keyCode != (char) KeyboardListener.KEY_UP) && (keyCode != (char) KeyboardListener.KEY_RIGHT) && (keyCode != (char) KeyboardListener.KEY_DOWN)) { ((TextBox) sender).cancelKey(); } } }
From source file:org.iucn.sis.client.ui.TreeTable.java
License:Apache License
@Override public void onBrowserEvent(Event event) { int eventType = DOM.eventGetType(event); switch (eventType) { case Event.ONCLICK: { Element e = DOM.eventGetTarget(event); if (shouldTreeDelegateFocusToElement(e)) { // The click event should have given focus to this element // already. // Avoid moving focus back up to the tree (so that focusable // widgets // attached to TreeItems can receive keyboard events). } else {//from ww w . j av a 2s . c o m // setFocus(true); } break; } case Event.ONMOUSEDOWN: { if (mouseListeners != null) { mouseListeners.fireMouseEvent(this, event); } elementClicked(root, DOM.eventGetTarget(event)); break; } case Event.ONMOUSEUP: { if (mouseListeners != null) { mouseListeners.fireMouseEvent(this, event); } break; } case Event.ONMOUSEMOVE: { if (mouseListeners != null) { mouseListeners.fireMouseEvent(this, event); } break; } case Event.ONMOUSEOVER: { if (mouseListeners != null) { mouseListeners.fireMouseEvent(this, event); } break; } case Event.ONMOUSEOUT: { if (mouseListeners != null) { mouseListeners.fireMouseEvent(this, event); } break; } // case Event.ONFOCUS: // // If we already have focus, ignore the focus event. // if (focusListeners != null) { // focusListeners.fireFocusEvent(this, event); // } // break; // // case Event.ONBLUR: { // if (focusListeners != null) { // focusListeners.fireFocusEvent(this, event); // } // // break; // } case Event.ONKEYDOWN: // If nothing's selected, select the first item. if (curSelection == null) { if (root.getChildCount() > 0) { onSelection(root.getChild(0), true); } super.onBrowserEvent(event); return; } if (lastEventType == Event.ONKEYDOWN) { // Two key downs in a row signal a duplicate event. Multiple key // downs can be triggered in the current configuration // independent // of the browser. return; } // Handle keyboard events switch (DOM.eventGetKeyCode(event)) { case KeyboardListener.KEY_UP: { moveSelectionUp(curSelection); DOM.eventPreventDefault(event); break; } case KeyboardListener.KEY_DOWN: { moveSelectionDown(curSelection, true); DOM.eventPreventDefault(event); break; } case KeyboardListener.KEY_LEFT: { if (curSelection.getState()) { curSelection.setState(false); } DOM.eventPreventDefault(event); break; } case KeyboardListener.KEY_RIGHT: { if (!curSelection.getState()) { curSelection.setState(true); } DOM.eventPreventDefault(event); break; } default: break; } // Intentional fallthrough. case Event.ONKEYUP: if (eventType == Event.ONKEYUP) { // If we got here because of a key tab, then we need to make // sure the // current tree item is selected. if (DOM.eventGetKeyCode(event) == KeyboardListener.KEY_TAB) { Vector chain = new Vector(); collectElementChain(chain, getElement(), DOM.eventGetTarget(event)); TreeItem item = findItemByChain(chain, 0, root); if (item != getSelectedItem()) { setSelectedItem(item, true); } } } // Intentional fallthrough. case Event.ONKEYPRESS: { if (keyboardListeners != null) { keyboardListeners.fireKeyboardEvent(this, event); } break; } } // We must call SynthesizedWidget's implementation for all other events. super.onBrowserEvent(event); lastEventType = eventType; }
From source file:org.pentaho.gwt.widgets.client.colorpicker.ColorPicker.java
License:Artistic License
/** * Fired when a keyboard action generates a character. This occurs after onKeyDown and onKeyUp are fired for the * physical key that was pressed./*from w ww . java 2 s . c om*/ * * It should be noted that many browsers do not generate keypress events for non-printing keyCode values, such as * KEY_ENTER or arrow keys. These keyCodes can be reliably captured either with onKeyDown(Widget, char, int) or * onKeyUp(Widget, char, int). * * Subclasses that override this method must call <tt>super.onKeyPress(sender, keyCode, modifiers)</tt> to ensure that * the Widget recieves its events. * * @param sender * the widget that was focused when the event occurred. * @param keyCode * the Unicode character that was generated by the keyboard action. * @param modifiers * the modifier keys pressed at when the event occurred. This value is a combination of the bits defined by * MODIFIER_SHIFT, MODIFIER_CTRL, and MODIFIER_ALT. * @see com.google.gwt.user.client.ui.KeyboardListener */ public void onKeyPress(Widget sender, char keyCode, int modifiers) { if (sender == tbHexColor) { // Disallow non-hex in hexadecimal boxes if ((!Character.isDigit(keyCode)) && (keyCode != 'A') && (keyCode != 'a') && (keyCode != 'B') && (keyCode != 'b') && (keyCode != 'C') && (keyCode != 'c') && (keyCode != 'D') && (keyCode != 'd') && (keyCode != 'E') && (keyCode != 'e') && (keyCode != 'F') && (keyCode != 'f') && (keyCode != (char) KeyboardListener.KEY_TAB) && (keyCode != (char) KeyboardListener.KEY_BACKSPACE) && (keyCode != (char) KeyboardListener.KEY_DELETE) && (keyCode != (char) KeyboardListener.KEY_ENTER) && (keyCode != (char) KeyboardListener.KEY_HOME) && (keyCode != (char) KeyboardListener.KEY_END) && (keyCode != (char) KeyboardListener.KEY_LEFT) && (keyCode != (char) KeyboardListener.KEY_UP) && (keyCode != (char) KeyboardListener.KEY_RIGHT) && (keyCode != (char) KeyboardListener.KEY_DOWN)) { ((TextBox) sender).cancelKey(); } } else { // Disallow non-numerics in numeric boxes if ((!Character.isDigit(keyCode)) && (keyCode != (char) KeyboardListener.KEY_TAB) && (keyCode != (char) KeyboardListener.KEY_BACKSPACE) && (keyCode != (char) KeyboardListener.KEY_DELETE) && (keyCode != (char) KeyboardListener.KEY_ENTER) && (keyCode != (char) KeyboardListener.KEY_HOME) && (keyCode != (char) KeyboardListener.KEY_END) && (keyCode != (char) KeyboardListener.KEY_LEFT) && (keyCode != (char) KeyboardListener.KEY_UP) && (keyCode != (char) KeyboardListener.KEY_RIGHT) && (keyCode != (char) KeyboardListener.KEY_DOWN)) { ((TextBox) sender).cancelKey(); } } }
From source file:org.pentaho.ui.xul.gwt.tags.GwtTextbox.java
License:Open Source License
@SuppressWarnings("deprecation") private void setupListeners() { textBox.addKeyboardListener(new KeyboardListener() { public void onKeyDown(Widget sender, char keyCode, int modifiers) { if (onblur != null && !onblur.equalsIgnoreCase("")) { //$NON-NLS-1$ if (keyCode == KeyboardListener.KEY_TAB) { Event.getCurrentEvent().cancelBubble(true); Event.getCurrentEvent().preventDefault(); try { GwtTextbox.this.getXulDomContainer().invoke(GwtTextbox.this.getOnblur(), new Object[] {}); } catch (XulException e) { e.printStackTrace(); }/*w w w. ja va 2 s . co m*/ } } } public void onKeyPress(Widget sender, char keyCode, int modifiers) { } public void onKeyUp(Widget sender, char keyCode, int modifiers) { setValue(textBox.getText()); if (keyCode == KeyboardListener.KEY_ENTER) { if (!GwtTextbox.this.multiline) { try { GwtTextbox.this.getXulDomContainer().invoke(GwtTextbox.this.getOncommand(), new Object[] {}); } catch (XulException e) { e.printStackTrace(); } } } } }); textBox.addBlurHandler(new BlurHandler() { public void onBlur(BlurEvent event) { if (onblur != null && !onblur.equalsIgnoreCase("")) { //$NON-NLS-1$ try { GwtTextbox.this.getXulDomContainer().invoke(GwtTextbox.this.getOnblur(), new Object[] {}); } catch (XulException e) { e.printStackTrace(); } } } }); }