public class

ValueBoxBase

extends FocusWidget
implements IsEditor<E extends Editor<?>> HasChangeHandlers AutoDirectionHandler.Target HasDirectionEstimator HasName HasValue<T>
java.lang.Object
   ↳ com.google.gwt.user.client.ui.UIObject
     ↳ com.google.gwt.user.client.ui.Widget
       ↳ com.google.gwt.user.client.ui.FocusWidget
         ↳ com.google.gwt.user.client.ui.ValueBoxBase<T>
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Abstract base class for all text entry widgets.

Use in UiBinder Templates

Summary

Nested Classes
enum ValueBoxBase.TextAlignment Alignment values for setAlignment(ValueBoxBase.TextAlignment)
[Expand]
Inherited Constants
From class com.google.gwt.user.client.ui.UIObject
Protected Constructors
ValueBoxBase(Element elem, Renderer<T> renderer, Parser<T> parser)
Creates a value box that wraps the given browser element handle.
Public Methods
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.
String getName()
Gets the widget's name.
String getSelectedText()
Gets the text currently selected within this text box.
int getSelectionLength()
Gets the length of the current text selection.
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.
void removeChangeListener(ChangeListener listener)
This method is deprecated. Use the removeHandler() method on the object returned by addChangeHandler(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(DirectionEstimator directionEstimator)
Sets the direction estimation model of the auto-dir handler.
void setDirectionEstimator(boolean enabled)
Toggles on / off direction estimation.
void setKey(char key)
This method is deprecated. this method only works in IE and should not have been added to the API
void setName(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(String text)
Sets this object's text.
void setValue(T value, boolean fireEvents)
Sets this object's value.
void setValue(T value)
Sets this object's value without firing any events.
Protected Methods
TextBoxImpl getImpl()
void onLoad()
This method is called immediately after a widget becomes attached to the browser's document.
[Expand]
Inherited Methods
From class com.google.gwt.user.client.ui.FocusWidget
From class com.google.gwt.user.client.ui.Widget
From class com.google.gwt.user.client.ui.UIObject
From class java.lang.Object
From interface com.google.gwt.editor.client.IsEditor
From interface com.google.gwt.event.dom.client.HasBlurHandlers
From interface com.google.gwt.event.dom.client.HasChangeHandlers
From interface com.google.gwt.event.dom.client.HasClickHandlers
From interface com.google.gwt.event.dom.client.HasDoubleClickHandlers
From interface com.google.gwt.event.dom.client.HasFocusHandlers
From interface com.google.gwt.event.dom.client.HasGestureChangeHandlers
From interface com.google.gwt.event.dom.client.HasGestureEndHandlers
From interface com.google.gwt.event.dom.client.HasGestureStartHandlers
From interface com.google.gwt.event.dom.client.HasKeyDownHandlers
From interface com.google.gwt.event.dom.client.HasKeyPressHandlers
From interface com.google.gwt.event.dom.client.HasKeyUpHandlers
From interface com.google.gwt.event.dom.client.HasMouseDownHandlers
From interface com.google.gwt.event.dom.client.HasMouseMoveHandlers
From interface com.google.gwt.event.dom.client.HasMouseOutHandlers
From interface com.google.gwt.event.dom.client.HasMouseOverHandlers
From interface com.google.gwt.event.dom.client.HasMouseUpHandlers
From interface com.google.gwt.event.dom.client.HasMouseWheelHandlers
From interface com.google.gwt.event.dom.client.HasTouchCancelHandlers
From interface com.google.gwt.event.dom.client.HasTouchEndHandlers
From interface com.google.gwt.event.dom.client.HasTouchMoveHandlers
From interface com.google.gwt.event.dom.client.HasTouchStartHandlers
From interface com.google.gwt.event.logical.shared.HasAttachHandlers
From interface com.google.gwt.event.logical.shared.HasValueChangeHandlers
From interface com.google.gwt.event.shared.HasHandlers
From interface com.google.gwt.i18n.client.HasDirection
From interface com.google.gwt.i18n.shared.HasDirectionEstimator
From interface com.google.gwt.user.client.EventListener
From interface com.google.gwt.user.client.TakesValue
From interface com.google.gwt.user.client.ui.Focusable
From interface com.google.gwt.user.client.ui.HasEnabled
From interface com.google.gwt.user.client.ui.HasName
From interface com.google.gwt.user.client.ui.HasText
From interface com.google.gwt.user.client.ui.HasValue
From interface com.google.gwt.user.client.ui.IsWidget
From interface com.google.gwt.user.client.ui.SourcesClickEvents
From interface com.google.gwt.user.client.ui.SourcesFocusEvents
From interface com.google.gwt.user.client.ui.SourcesKeyboardEvents
From interface com.google.gwt.user.client.ui.SourcesMouseEvents

Protected Constructors

protected ValueBoxBase (Element elem, Renderer<T> renderer, Parser<T> parser)

Creates a value box that wraps the given browser element handle. This is only used by subclasses.

Parameters
elem the browser element to wrap

Public Methods

public HandlerRegistration addChangeHandler (ChangeHandler handler)

Adds a ChangeEvent handler.

Parameters
handler the change handler
Returns

public HandlerRegistration addValueChangeHandler (ValueChangeHandler<T> handler)

Adds a ValueChangeEvent handler.

Parameters
handler the handler
Returns
  • the registration for the event

public ValueBoxEditor<T> asEditor ()

Returns an Editor that is backed by the ValueBoxBase. The default implementation returns of(ValueBoxBase). Subclasses may override this method to provide custom error-handling when using the Editor framework.

Returns

public void cancelKey ()

If a keyboard event is currently being handled on this text box, calling this method will suppress it. This allows listeners to easily filter keyboard input.

public int getCursorPos ()

Gets the current position of the cursor (this also serves as the beginning of the text selection).

Returns
  • the cursor's position

public HasDirection.Direction getDirection ()

Gets the directionality of the widget.

Returns
  • RTL if the directionality is right-to-left, LTR if the directionality is left-to-right, or DEFAULT if the directionality is not explicitly specified

public DirectionEstimator getDirectionEstimator ()

Gets the direction estimation model of the auto-dir handler.

public String getName ()

Gets the widget's name.

Returns
  • the widget's name

public String getSelectedText ()

Gets the text currently selected within this text box.

Returns
  • the selected text, or an empty string if none is selected

public int getSelectionLength ()

Gets the length of the current text selection.

Returns
  • the text selection length

public String getText ()

Gets this object's text.

Returns
  • the object's text

public T getValue ()

Return the parsed value, or null if the field is empty or parsing fails.

Returns
  • the object's value

public T getValueOrThrow ()

Return the parsed value, or null if the field is empty.

Throws
ParseException if the value cannot be parsed

public boolean isReadOnly ()

Determines whether or not the widget is read-only.

Returns
  • true if the widget is currently read-only, false if the widget is currently editable

public void onBrowserEvent (Event event)

Fired whenever a browser event is received.

Parameters
event the event received

public void removeChangeListener (ChangeListener listener)

This method is deprecated.
Use the removeHandler() method on the object returned by addChangeHandler(ChangeHandler) instead

public void selectAll ()

Selects all of the text in the box. This will only work when the widget is attached to the document and not hidden.

public void setAlignment (ValueBoxBase.TextAlignment align)

public void setCursorPos (int pos)

Sets the cursor position. This will only work when the widget is attached to the document and not hidden.

Parameters
pos the new cursor position

public void setDirection (HasDirection.Direction direction)

Sets the directionality for a widget.

Parameters
direction 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 set

public void setDirectionEstimator (DirectionEstimator directionEstimator)

Sets the direction estimation model of the auto-dir handler.

Parameters
directionEstimator The {code DirectionEstimator} to be set. null means turning off direction estimation.

public void setDirectionEstimator (boolean enabled)

Toggles on / off direction estimation.

Parameters
enabled Whether to enable direction estimation. If true, sets the DirectionEstimator object to a default DirectionEstimator.

public void setKey (char key)

This method is deprecated.
this method only works in IE and should not have been added to the API

If a keyboard event is currently being handled by the text box, this method replaces the unicode character or key code associated with it. This allows listeners to easily filter keyboard input.

Parameters
key the new key value

public void setName (String name)

Sets the widget's name.

Parameters
name the widget's new name

public void setReadOnly (boolean readOnly)

Turns read-only mode on or off.

Parameters
readOnly if true, the widget becomes read-only; if false the widget becomes editable

public void setSelectionRange (int pos, int length)

Sets the range of text to be selected. This will only work when the widget is attached to the document and not hidden.

Parameters
pos the position of the first character to be selected
length the number of characters to be selected

public void setText (String text)

Sets this object's text. Note that some browsers will manipulate the text before adding it to the widget. For example, most browsers will strip all \r from the text, except IE which will add a \r before each \n. Use getText() to get the text directly from the widget.

Parameters
text the object's new text

public void setValue (T value, boolean fireEvents)

Sets this object's value. Fires ValueChangeEvent 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.

Parameters
value the object's new value
fireEvents fire events if true and value is new

public void setValue (T value)

Sets this object's value without firing any events. This should be identical to calling setValue(value, false).

It 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.

Parameters
value the object's new value

Protected Methods

protected TextBoxImpl getImpl ()

protected void onLoad ()

This method is called immediately after a widget becomes attached to the browser's document.