List of usage examples for com.google.gwt.user.client.ui FocusWidget addKeyUpHandler
public HandlerRegistration addKeyUpHandler(KeyUpHandler handler)
From source file:io.pelle.mango.client.gwt.ControlHelper.java
License:Open Source License
public <ValueType> ControlHelper(final Widget widget, final IBaseControl<?, ? extends IBaseControlModel> baseControl, IGwtControl gwtControl, boolean addValueChangeListener, boolean addDefaultStyle, boolean setWidth) { this.uiObject = widget; this.baseControl = baseControl; this.gwtControl = gwtControl; if (addDefaultStyle) { widget.addStyleName(Styles.FORM_CONTROL); }//from w ww.j a v a2 s .c om if (baseControl.isReadonly()) { widget.getElement().setPropertyBoolean("disabled", baseControl.isReadonly()); widget.addStyleName(GwtStyles.CONTROL_DISABLED_STYLE); } if (setWidth) { widget.setWidth(WidthCalculationStrategy.getInstance().getControlWidthCss(baseControl.getModel())); } baseControl.addUpdateListener(this); if (widget instanceof HasValue<?>) { final HasValue<ValueType> hasValueWidget = (HasValue<ValueType>) widget; if (addValueChangeListener) { if (widget instanceof FocusWidget) { FocusWidget focusWidget = (FocusWidget) widget; focusWidget.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { setParseValue(hasValueWidget.getValue()); } }); } } widget.addDomHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { baseControl.endEdit(); } }, BlurEvent.getType()); } onUpdate(); }
From source file:org.rebioma.client.forms.FormInput.java
License:Apache License
/** * Constructs a new form input with the given title and widget. The widget * must implement {@link SourcesKeyboardEvents}. * //from www . jav a 2s. c om * @param inputTitle the title of this input * @param inputWidget form input that implements {@link SourcesKeyboardEvents} * */ public FormInput(String inputTitle, FocusWidget inputWidget, boolean validate) { validateInput = validate; if (inputTitle != null) { title = new Label(); title.setText(inputTitle + ":"); title.setStyleName("rebioma-FormInput-title"); mainPanel.add(title); } widget = inputWidget; widget.setStyleName("rebioma-FormInput-widget"); mainPanel.setSpacing(5); mainPanel.add(inputWidget); initWidget(mainPanel); // Notifies change listeners when a character has been generated: inputWidget.addKeyUpHandler(new KeyUpHandler() { public void onKeyUp(KeyUpEvent event) { getThis().keyCode = event.getNativeKeyCode(); changeListeners.fireChange(getThis()); } }); }