T - the value typepublic class ValueBoxBase<T> extends FocusWidget implements HasChangeHandlers, HasName, HasDirectionEstimator, HasValue<T>, HasText, AutoDirectionHandler.Target, IsEditor<ValueBoxEditor<T>>
| Modifier and Type | Class and Description |
|---|---|
static class |
ValueBoxBase.TextAlignment
Alignment values for
setAlignment(com.google.gwt.user.client.ui.ValueBoxBase.TextAlignment). |
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabledHasDirection.DirectioneventsToSinkDEBUG_ID_PREFIX, MISSING_ELEMENT_ERROR, SETELEMENT_TWICE_ERROR| Modifier | Constructor and Description |
|---|---|
protected |
ValueBoxBase(Element elem,
Renderer<T> renderer,
Parser<T> parser)
Creates a value box that wraps the given browser element handle.
|
| Modifier and Type | Method and Description |
|---|---|
HandlerRegistration |
addChangeHandler(ChangeHandler handler)
Adds a
ChangeEvent handler. |
HandlerRegistration |
addValueChangeHandler(ValueChangeHandler<T> handler)
Adds a
ValueChangeEvent handler. |
ValueBoxEditor<T> |
asEditor()
Returns an Editor that is backed by the ValueBoxBase.
|
void |
cancelKey()
If a keyboard event is currently being handled on this text box, calling
this method will suppress it.
|
int |
getCursorPos()
Gets the current position of the cursor (this also serves as the beginning
of the text selection).
|
HasDirection.Direction |
getDirection()
Gets the directionality of the widget.
|
DirectionEstimator |
getDirectionEstimator()
Gets the direction estimation model of the auto-dir handler.
|
protected com.google.gwt.user.client.ui.impl.TextBoxImpl |
getImpl() |
java.lang.String |
getName()
Gets the widget's name.
|
java.lang.String |
getSelectedText()
Gets the text currently selected within this text box.
|
int |
getSelectionLength()
Gets the length of the current text selection.
|
java.lang.String |
getText()
Gets this object's text.
|
T |
getValue()
Return the parsed value, or null if the field is empty or parsing fails.
|
T |
getValueOrThrow()
Return the parsed value, or null if the field is empty.
|
boolean |
isReadOnly()
Determines whether or not the widget is read-only.
|
void |
onBrowserEvent(Event event)
Fired whenever a browser event is received.
|
protected void |
onLoad()
This method is called immediately after a widget becomes attached to the
browser's document.
|
void |
removeChangeListener(ChangeListener listener)
Deprecated.
Use the
HandlerRegistration.removeHandler() method on the
object returned by addChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) instead |
void |
selectAll()
Selects all of the text in the box.
|
void |
setAlignment(ValueBoxBase.TextAlignment align) |
void |
setCursorPos(int pos)
Sets the cursor position.
|
void |
setDirection(HasDirection.Direction direction)
Sets the directionality for a widget.
|
void |
setDirectionEstimator(boolean enabled)
Toggles on / off direction estimation.
|
void |
setDirectionEstimator(DirectionEstimator directionEstimator)
Sets the direction estimation model of the auto-dir handler.
|
void |
setKey(char key)
Deprecated.
this method only works in IE and should not have been added to
the API
|
void |
setName(java.lang.String name)
Sets the widget's name.
|
void |
setReadOnly(boolean readOnly)
Turns read-only mode on or off.
|
void |
setSelectionRange(int pos,
int length)
Sets the range of text to be selected.
|
void |
setText(java.lang.String text)
Sets this object's text.
|
void |
setValue(T value)
Sets this object's value without firing any events.
|
void |
setValue(T value,
boolean fireEvents)
Sets this object's value.
|
addBlurHandler, addClickHandler, addClickListener, addDoubleClickHandler, addDragEndHandler, addDragEnterHandler, addDragHandler, addDragLeaveHandler, addDragOverHandler, addDragStartHandler, addDropHandler, addFocusHandler, addFocusListener, addGestureChangeHandler, addGestureEndHandler, addGestureStartHandler, addKeyboardListener, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, addMouseDownHandler, addMouseListener, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler, addMouseWheelListener, addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler, getFocusImpl, getTabIndex, isEnabled, onAttach, removeClickListener, removeFocusListener, removeKeyboardListener, removeMouseListener, removeMouseWheelListener, setAccessKey, setEnabled, setFocus, setTabIndexaddAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, ensureHandlers, fireEvent, getHandlerCount, getHandlerManager, getLayoutData, getParent, isAttached, isOrWasAttached, onDetach, onUnload, removeFromParent, replaceElement, setLayoutData, setParent, sinkEvents, unsinkEventsaddStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddKeyUpHandlerfireEventpublic HandlerRegistration addChangeHandler(ChangeHandler handler)
HasChangeHandlersChangeEvent handler.addChangeHandler in interface HasChangeHandlershandler - the change handlerHandlerRegistration used to remove this handlerpublic HandlerRegistration addValueChangeHandler(ValueChangeHandler<T> handler)
HasValueChangeHandlersValueChangeEvent handler.addValueChangeHandler in interface HasValueChangeHandlers<T>handler - the handlerpublic ValueBoxEditor<T> asEditor()
ValueBoxEditor.of(ValueBoxBase). Subclasses
may override this method to provide custom error-handling when using the
Editor framework.asEditor in interface IsEditor<ValueBoxEditor<T>>Editor of type Epublic void cancelKey()
public int getCursorPos()
public HasDirection.Direction getDirection()
HasDirectiongetDirection in interface HasDirectionRTL if the directionality is right-to-left,
LTR if the directionality is left-to-right, or
DEFAULT if the directionality is not explicitly specifiedpublic DirectionEstimator getDirectionEstimator()
getDirectionEstimator in interface HasDirectionEstimatorpublic java.lang.String getName()
HasNamepublic java.lang.String getSelectedText()
public int getSelectionLength()
public java.lang.String getText()
HasTextgetText in interface AutoDirectionHandler.TargetgetText in interface HasTextpublic T getValue()
getValue in interface TakesValue<T>getValue in interface HasValue<T>TakesValue.setValue(V)public T getValueOrThrow() throws java.text.ParseException
java.text.ParseException - if the value cannot be parsedpublic boolean isReadOnly()
true if the widget is currently read-only,
false if the widget is currently editablepublic void onBrowserEvent(Event event)
EventListeneronBrowserEvent in interface EventListeneronBrowserEvent in class Widgetevent - the event received@Deprecated public void removeChangeListener(ChangeListener listener)
HandlerRegistration.removeHandler() method on the
object returned by addChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) insteadpublic void selectAll()
public void setAlignment(ValueBoxBase.TextAlignment align)
public void setCursorPos(int pos)
pos - the new cursor positionpublic void setDirection(HasDirection.Direction direction)
HasDirectionsetDirection in interface HasDirectiondirection - RTL if the directionality should be set to right-to-left,
LTR if the directionality should be set to left-to-right
DEFAULT if the directionality should not be explicitly setpublic void setDirectionEstimator(boolean enabled)
setDirectionEstimator in interface HasDirectionEstimatorenabled - Whether to enable direction estimation. If true,
sets the DirectionEstimator object to a default
DirectionEstimator.public void setDirectionEstimator(DirectionEstimator directionEstimator)
setDirectionEstimator in interface HasDirectionEstimatordirectionEstimator - The DirectionEstimator to be set. null means turning off direction estimation.@Deprecated public void setKey(char key)
key - the new key valuepublic void setName(java.lang.String name)
HasNamepublic void setReadOnly(boolean readOnly)
readOnly - if true, the widget becomes read-only; if
false the widget becomes editablepublic void setSelectionRange(int pos,
int length)
pos - the position of the first character to be selectedlength - the number of characters to be selectedpublic void setText(java.lang.String text)
\r from the text, except IE which will add a \r
before each \n. Use getText() to get the text
directly from the widget.setText in interface AutoDirectionHandler.TargetsetText in interface HasTexttext - the object's new textpublic void setValue(T value)
HasValueIt is acceptable to fail assertions or throw (documented) unchecked exceptions in response to bad values.
Widgets must accept null as a valid value. By convention, setting a widget to
null clears value, calling getValue() on a cleared widget returns null. Widgets
that can not be cleared (e.g. CheckBox) must find another valid meaning
for null input.
setValue in interface TakesValue<T>setValue in interface HasValue<T>value - the object's new valueTakesValue.getValue()public void setValue(T value, boolean fireEvents)
HasValueValueChangeEvent when
fireEvents is true and the new value does not equal the existing value.
It is acceptable to fail assertions or throw (documented) unchecked exceptions in response to bad values.
protected com.google.gwt.user.client.ui.impl.TextBoxImpl getImpl()