/** * 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(); } } ); }
public void setKeyTyped(JavaScriptObject aValue) { if (keyTyped != aValue) { if (keyTypedReg != null) { keyTypedReg.removeHandler(); keyTypedReg = null; } keyTyped = aValue; if (keyTyped != null && component instanceof HasKeyPressHandlers) { keyTypedReg = ((HasKeyPressHandlers) component).addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { if (keyTyped != null) { event.stopPropagation(); executeEvent(keyTyped, EventsPublisher.publish(event)); } } }); } } }
/** * initialize one editor. * * @param editor editor to initialize */ @SuppressWarnings({"rawtypes", "unchecked"}) public void initializeEditors(final Object editor) { if (editor instanceof HasValueChangeHandlers && this.valueChangeHandler != null) { ((HasValueChangeHandlers) editor).addValueChangeHandler(this.valueChangeHandler); // if widget has a value change handler, validate on change if (this.validateOnVueChangeHandler != null) { ((HasValueChangeHandlers) editor).addValueChangeHandler(this.validateOnVueChangeHandler); } } // if widget has a key up handler, validate on key up if (editor instanceof HasKeyUpHandlers && this.validateOnKeyUpHandler != null) { ((HasKeyUpHandlers) editor).addKeyUpHandler(this.validateOnKeyUpHandler); } // try to submit form on return if (editor instanceof HasKeyPressHandlers && this.commitOnReturnHandler != null) { ((HasKeyPressHandlers) editor).addKeyPressHandler(this.commitOnReturnHandler); } }
/** * Sets the KeyPress() event handler in many widgets * @param handler the handler * @param widgets the widgets */ public static void addKeyPressHandler(final KeyPressHandler handler,final HasKeyPressHandlers... widgets) { if (handler != null && widgets != null && widgets.length > 0) { for (HasKeyPressHandlers w : widgets) { if (w != null) w.addKeyPressHandler(handler); } } }
@Override public final HandlerRegistration addKeyPressHandler(final KeyPressHandler phandler) { if (this.contents.getWidget() instanceof HasKeyPressHandlers) { return ((HasKeyPressHandlers) this.contents.getWidget()).addKeyPressHandler(phandler); } else { return null; } }
@Override public HasKeyPressHandlers getLoginKeyPress() { return login; }
@Override public HasKeyPressHandlers getPasswdKeyPress() { return passwd; }
@Override public HasKeyPressHandlers getTextBox() { return m_tf; }
HasKeyPressHandlers getLoginKeyPress();
HasKeyPressHandlers getPasswdKeyPress();
HasKeyPressHandlers getTextBox();