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.DebugIdImplEnabled
HasDirection.Direction
eventsToSink
DEBUG_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, setTabIndex
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, ensureHandlers, fireEvent, getHandlerCount, getHandlerManager, getLayoutData, getParent, isAttached, isOrWasAttached, onDetach, onUnload, removeFromParent, replaceElement, setLayoutData, setParent, sinkEvents, unsinkEvents
addStyleDependentName, 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, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addKeyUpHandler
fireEvent
public HandlerRegistration addChangeHandler(ChangeHandler handler)
HasChangeHandlers
ChangeEvent
handler.addChangeHandler
in interface HasChangeHandlers
handler
- the change handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addValueChangeHandler(ValueChangeHandler<T> handler)
HasValueChangeHandlers
ValueChangeEvent
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()
HasDirection
getDirection
in interface HasDirection
RTL
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 HasDirectionEstimator
public java.lang.String getName()
HasName
public java.lang.String getSelectedText()
public int getSelectionLength()
public java.lang.String getText()
HasText
getText
in interface AutoDirectionHandler.Target
getText
in interface HasText
public 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)
EventListener
onBrowserEvent
in interface EventListener
onBrowserEvent
in class Widget
event
- 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)
HasDirection
setDirection
in interface HasDirection
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 setpublic void setDirectionEstimator(boolean enabled)
setDirectionEstimator
in interface HasDirectionEstimator
enabled
- Whether to enable direction estimation. If true
,
sets the DirectionEstimator
object to a default
DirectionEstimator
.public void setDirectionEstimator(DirectionEstimator directionEstimator)
setDirectionEstimator
in interface HasDirectionEstimator
directionEstimator
- 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)
HasName
public 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.Target
setText
in interface HasText
text
- the object's new textpublic void setValue(T value)
HasValue
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.
setValue
in interface TakesValue<T>
setValue
in interface HasValue<T>
value
- the object's new valueTakesValue.getValue()
public void setValue(T value, boolean fireEvents)
HasValue
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.
protected com.google.gwt.user.client.ui.impl.TextBoxImpl getImpl()