T
- the input Widget to wrap.public class TextfieldBase<T extends com.google.gwt.user.client.ui.TextBoxBase> extends com.google.gwt.user.client.ui.FlowPanel implements com.google.gwt.user.client.ui.Focusable, com.google.gwt.event.dom.client.HasChangeHandlers, com.google.gwt.user.client.ui.HasName, com.google.gwt.i18n.shared.HasDirectionEstimator, com.google.gwt.user.client.ui.HasValue<String>, com.google.gwt.user.client.ui.HasText, com.google.gwt.i18n.client.AutoDirectionHandler.Target, com.google.gwt.editor.client.IsEditor<com.google.gwt.editor.ui.client.adapters.ValueBoxEditor<String>>, com.google.gwt.event.dom.client.HasClickHandlers, com.google.gwt.event.dom.client.HasDoubleClickHandlers, com.google.gwt.user.client.ui.HasEnabled, com.google.gwt.event.dom.client.HasAllDragAndDropHandlers, com.google.gwt.event.dom.client.HasAllFocusHandlers, com.google.gwt.event.dom.client.HasAllGestureHandlers, com.google.gwt.event.dom.client.HasAllKeyHandlers, com.google.gwt.event.dom.client.HasAllMouseHandlers, com.google.gwt.event.dom.client.HasAllTouchHandlers, ITextBox, IsTextBoxBase<T>, IsValueBoxBase<String>, IUpgrade
Material design lite provides three options to type text.
TextfieldBase
holds common features for text based material
components. The DOM structure of a text field is simple. At the top level, a
div
element contains an input
element, a
div
element to set the label to displayed inside the input and a
span
to display an error message below the input box when the
input text does not comply to the validation rule.
The TextfieldBase
uses a TextBoxBase
under the hood to handle
the input. The exact instance of input Widget to wrap is provided from the
outside to insure a better flexibility. Wrappings for the usual GWT input
Widgets are provided out of the box.
TextField
for TextBox
PasswordField
for PasswordTextBox
MultilineTextField
for TextArea
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
com.google.gwt.i18n.client.HasDirection.Direction
Constructor and Description |
---|
TextfieldBase(String inputLabel,
T inputBox)
Setup a new instance of
TextfieldBase type and provide a label. |
TextfieldBase(T inputBox)
Setup an instance of
TextfieldBase type. |
Modifier and Type | Method and Description |
---|---|
com.google.gwt.event.shared.HandlerRegistration |
addBlurHandler(com.google.gwt.event.dom.client.BlurHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addChangeHandler(com.google.gwt.event.dom.client.ChangeHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addClickHandler(com.google.gwt.event.dom.client.ClickHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addDoubleClickHandler(com.google.gwt.event.dom.client.DoubleClickHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addDragEndHandler(com.google.gwt.event.dom.client.DragEndHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addDragEnterHandler(com.google.gwt.event.dom.client.DragEnterHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addDragHandler(com.google.gwt.event.dom.client.DragHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addDragLeaveHandler(com.google.gwt.event.dom.client.DragLeaveHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addDragOverHandler(com.google.gwt.event.dom.client.DragOverHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addDragStartHandler(com.google.gwt.event.dom.client.DragStartHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addDropHandler(com.google.gwt.event.dom.client.DropHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addFocusHandler(com.google.gwt.event.dom.client.FocusHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addGestureChangeHandler(com.google.gwt.event.dom.client.GestureChangeHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addGestureEndHandler(com.google.gwt.event.dom.client.GestureEndHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addGestureStartHandler(com.google.gwt.event.dom.client.GestureStartHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addKeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addKeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addKeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addMouseDownHandler(com.google.gwt.event.dom.client.MouseDownHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addMouseMoveHandler(com.google.gwt.event.dom.client.MouseMoveHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addMouseOutHandler(com.google.gwt.event.dom.client.MouseOutHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addMouseOverHandler(com.google.gwt.event.dom.client.MouseOverHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addMouseUpHandler(com.google.gwt.event.dom.client.MouseUpHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addMouseWheelHandler(com.google.gwt.event.dom.client.MouseWheelHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addTouchCancelHandler(com.google.gwt.event.dom.client.TouchCancelHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addTouchEndHandler(com.google.gwt.event.dom.client.TouchEndHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addTouchMoveHandler(com.google.gwt.event.dom.client.TouchMoveHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addTouchStartHandler(com.google.gwt.event.dom.client.TouchStartHandler handler) |
com.google.gwt.event.shared.HandlerRegistration |
addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<String> handler) |
com.google.gwt.editor.ui.client.adapters.ValueBoxEditor<String> |
asEditor() |
T |
asTextBoxBase() |
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).
|
com.google.gwt.i18n.client.HasDirection.Direction |
getDirection() |
com.google.gwt.i18n.shared.DirectionEstimator |
getDirectionEstimator() |
protected com.google.gwt.user.client.ui.Label |
getLabel()
The
TextfieldBase contains a Label under the hood to
display the hint inside the text box when it is empty. |
int |
getMaxLength()
Gets the maximum allowable length of the text box.
|
String |
getName() |
String |
getSelectedText()
Gets the text currently selected within this text box.
|
int |
getSelectionLength()
Gets the length of the current text selection.
|
int |
getTabIndex() |
String |
getText() |
String |
getValue() |
String |
getValueOrThrow()
Return the parsed value, or null if the field is empty.
|
int |
getVisibleLength()
Gets the number of visible characters in the text box.
|
boolean |
isEnabled() |
boolean |
isReadOnly()
Determines whether or not the widget is read-only.
|
boolean |
isUpgraded() |
void |
onBrowserEvent(com.google.gwt.user.client.Event event) |
protected void |
onLoad() |
void |
selectAll()
Selects all of the text in the box.
|
void |
setAccessKey(char key) |
void |
setAlignment(com.google.gwt.user.client.ui.ValueBoxBase.TextAlignment align) |
void |
setCursorPos(int pos)
Sets the cursor position.
|
void |
setDirection(com.google.gwt.i18n.client.HasDirection.Direction direction) |
void |
setDirectionEstimator(boolean enabled) |
void |
setDirectionEstimator(com.google.gwt.i18n.shared.DirectionEstimator directionEstimator) |
void |
setEnabled(boolean enabled) |
void |
setFloat(Float inputFloat)
Make the label float over the text box when the input acquires the focus.
|
void |
setFocus(boolean focused) |
void |
setLabel(String inputLabel)
Set the label of the text field.
|
void |
setMaxLength(int length)
Sets the maximum allowable length of the text box.
|
void |
setName(String 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 |
setTabIndex(int index) |
void |
setText(String text)
programmatically provides the input field with a text.
|
void |
setValue(String value) |
void |
setValue(String value,
boolean fireEvents) |
void |
setVisibleLength(int length)
Sets the number of visible characters in the text box.
|
void |
upgrade()
Causes the component to be upgraded.
|
add, add, adjustIndex, checkIndexBoundsForAccess, checkIndexBoundsForInsertion, getChildren, getWidget, getWidgetCount, getWidgetIndex, getWidgetIndex, insert, insert, iterator, remove, remove
add, adopt, doAttachChildren, doDetachChildren, orphan, remove
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onDetach, onUnload, removeFromParent, setLayoutData, 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
public TextfieldBase(T inputBox)
TextfieldBase
type. The appropriate input
Widget depends on the context and therefore provided from the outside.inputBox
- the input type to be usedpublic TextfieldBase(String inputLabel, T inputBox)
TextfieldBase
type and provide a label.inputLabel
- a hint to be displayed in the text box.inputBox
- the input Widget to be usedpublic final void setFloat(Float inputFloat)
inputFloat
- the floating state of the labelpublic final void setLabel(String inputLabel)
inputLabel
- a hint about the fieldpublic void setText(String text)
ValueBoxBase.setText(String)
and
makes sure the label is correctly positioned.setText
in interface com.google.gwt.i18n.client.AutoDirectionHandler.Target
setText
in interface com.google.gwt.user.client.ui.HasText
text
- the text to be fed to the input fieldpublic com.google.gwt.event.shared.HandlerRegistration addDragEndHandler(com.google.gwt.event.dom.client.DragEndHandler handler)
addDragEndHandler
in interface com.google.gwt.event.dom.client.HasDragEndHandlers
public com.google.gwt.event.shared.HandlerRegistration addDragEnterHandler(com.google.gwt.event.dom.client.DragEnterHandler handler)
addDragEnterHandler
in interface com.google.gwt.event.dom.client.HasDragEnterHandlers
public com.google.gwt.event.shared.HandlerRegistration addDragLeaveHandler(com.google.gwt.event.dom.client.DragLeaveHandler handler)
addDragLeaveHandler
in interface com.google.gwt.event.dom.client.HasDragLeaveHandlers
public com.google.gwt.event.shared.HandlerRegistration addDragHandler(com.google.gwt.event.dom.client.DragHandler handler)
addDragHandler
in interface com.google.gwt.event.dom.client.HasDragHandlers
public com.google.gwt.event.shared.HandlerRegistration addDragOverHandler(com.google.gwt.event.dom.client.DragOverHandler handler)
addDragOverHandler
in interface com.google.gwt.event.dom.client.HasDragOverHandlers
public com.google.gwt.event.shared.HandlerRegistration addDragStartHandler(com.google.gwt.event.dom.client.DragStartHandler handler)
addDragStartHandler
in interface com.google.gwt.event.dom.client.HasDragStartHandlers
public com.google.gwt.event.shared.HandlerRegistration addDropHandler(com.google.gwt.event.dom.client.DropHandler handler)
addDropHandler
in interface com.google.gwt.event.dom.client.HasDropHandlers
public com.google.gwt.event.shared.HandlerRegistration addFocusHandler(com.google.gwt.event.dom.client.FocusHandler handler)
addFocusHandler
in interface com.google.gwt.event.dom.client.HasFocusHandlers
public com.google.gwt.event.shared.HandlerRegistration addBlurHandler(com.google.gwt.event.dom.client.BlurHandler handler)
addBlurHandler
in interface com.google.gwt.event.dom.client.HasBlurHandlers
public com.google.gwt.event.shared.HandlerRegistration addGestureStartHandler(com.google.gwt.event.dom.client.GestureStartHandler handler)
addGestureStartHandler
in interface com.google.gwt.event.dom.client.HasGestureStartHandlers
public com.google.gwt.event.shared.HandlerRegistration addGestureChangeHandler(com.google.gwt.event.dom.client.GestureChangeHandler handler)
addGestureChangeHandler
in interface com.google.gwt.event.dom.client.HasGestureChangeHandlers
public com.google.gwt.event.shared.HandlerRegistration addGestureEndHandler(com.google.gwt.event.dom.client.GestureEndHandler handler)
addGestureEndHandler
in interface com.google.gwt.event.dom.client.HasGestureEndHandlers
public com.google.gwt.event.shared.HandlerRegistration addKeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler handler)
addKeyDownHandler
in interface com.google.gwt.event.dom.client.HasKeyDownHandlers
public com.google.gwt.event.shared.HandlerRegistration addKeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler handler)
addKeyPressHandler
in interface com.google.gwt.event.dom.client.HasKeyPressHandlers
public com.google.gwt.event.shared.HandlerRegistration addMouseDownHandler(com.google.gwt.event.dom.client.MouseDownHandler handler)
addMouseDownHandler
in interface com.google.gwt.event.dom.client.HasMouseDownHandlers
public com.google.gwt.event.shared.HandlerRegistration addMouseUpHandler(com.google.gwt.event.dom.client.MouseUpHandler handler)
addMouseUpHandler
in interface com.google.gwt.event.dom.client.HasMouseUpHandlers
public com.google.gwt.event.shared.HandlerRegistration addMouseOutHandler(com.google.gwt.event.dom.client.MouseOutHandler handler)
addMouseOutHandler
in interface com.google.gwt.event.dom.client.HasMouseOutHandlers
public com.google.gwt.event.shared.HandlerRegistration addMouseOverHandler(com.google.gwt.event.dom.client.MouseOverHandler handler)
addMouseOverHandler
in interface com.google.gwt.event.dom.client.HasMouseOverHandlers
public com.google.gwt.event.shared.HandlerRegistration addMouseMoveHandler(com.google.gwt.event.dom.client.MouseMoveHandler handler)
addMouseMoveHandler
in interface com.google.gwt.event.dom.client.HasMouseMoveHandlers
public com.google.gwt.event.shared.HandlerRegistration addMouseWheelHandler(com.google.gwt.event.dom.client.MouseWheelHandler handler)
addMouseWheelHandler
in interface com.google.gwt.event.dom.client.HasMouseWheelHandlers
public com.google.gwt.event.shared.HandlerRegistration addTouchStartHandler(com.google.gwt.event.dom.client.TouchStartHandler handler)
addTouchStartHandler
in interface com.google.gwt.event.dom.client.HasTouchStartHandlers
public com.google.gwt.event.shared.HandlerRegistration addTouchMoveHandler(com.google.gwt.event.dom.client.TouchMoveHandler handler)
addTouchMoveHandler
in interface com.google.gwt.event.dom.client.HasTouchMoveHandlers
public com.google.gwt.event.shared.HandlerRegistration addTouchEndHandler(com.google.gwt.event.dom.client.TouchEndHandler handler)
addTouchEndHandler
in interface com.google.gwt.event.dom.client.HasTouchEndHandlers
public com.google.gwt.event.shared.HandlerRegistration addTouchCancelHandler(com.google.gwt.event.dom.client.TouchCancelHandler handler)
addTouchCancelHandler
in interface com.google.gwt.event.dom.client.HasTouchCancelHandlers
public boolean isEnabled()
isEnabled
in interface com.google.gwt.user.client.ui.HasEnabled
public void setEnabled(boolean enabled)
setEnabled
in interface com.google.gwt.user.client.ui.HasEnabled
public com.google.gwt.event.shared.HandlerRegistration addDoubleClickHandler(com.google.gwt.event.dom.client.DoubleClickHandler handler)
addDoubleClickHandler
in interface com.google.gwt.event.dom.client.HasDoubleClickHandlers
public com.google.gwt.event.shared.HandlerRegistration addClickHandler(com.google.gwt.event.dom.client.ClickHandler handler)
addClickHandler
in interface com.google.gwt.event.dom.client.HasClickHandlers
public int getTabIndex()
getTabIndex
in interface com.google.gwt.user.client.ui.Focusable
public void setAccessKey(char key)
setAccessKey
in interface com.google.gwt.user.client.ui.Focusable
public void setFocus(boolean focused)
setFocus
in interface com.google.gwt.user.client.ui.Focusable
public void setTabIndex(int index)
setTabIndex
in interface com.google.gwt.user.client.ui.Focusable
public com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<String> handler)
addValueChangeHandler
in interface com.google.gwt.event.logical.shared.HasValueChangeHandlers<String>
public void setDirection(com.google.gwt.i18n.client.HasDirection.Direction direction)
setDirection
in interface com.google.gwt.i18n.client.HasDirection
public com.google.gwt.i18n.client.HasDirection.Direction getDirection()
getDirection
in interface com.google.gwt.i18n.client.HasDirection
public com.google.gwt.event.shared.HandlerRegistration addKeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler handler)
addKeyUpHandler
in interface com.google.gwt.event.dom.client.HasKeyUpHandlers
public com.google.gwt.editor.ui.client.adapters.ValueBoxEditor<String> asEditor()
asEditor
in interface com.google.gwt.editor.client.IsEditor<com.google.gwt.editor.ui.client.adapters.ValueBoxEditor<String>>
public String getText()
getText
in interface com.google.gwt.i18n.client.AutoDirectionHandler.Target
getText
in interface com.google.gwt.user.client.ui.HasText
public String getValue()
public void setValue(String value)
public void setValue(String value, boolean fireEvents)
setValue
in interface com.google.gwt.user.client.ui.HasValue<String>
public com.google.gwt.i18n.shared.DirectionEstimator getDirectionEstimator()
getDirectionEstimator
in interface com.google.gwt.i18n.shared.HasDirectionEstimator
public void setDirectionEstimator(boolean enabled)
setDirectionEstimator
in interface com.google.gwt.i18n.shared.HasDirectionEstimator
public void setDirectionEstimator(com.google.gwt.i18n.shared.DirectionEstimator directionEstimator)
setDirectionEstimator
in interface com.google.gwt.i18n.shared.HasDirectionEstimator
public void setName(String name)
setName
in interface com.google.gwt.user.client.ui.HasName
public String getName()
getName
in interface com.google.gwt.user.client.ui.HasName
public com.google.gwt.event.shared.HandlerRegistration addChangeHandler(com.google.gwt.event.dom.client.ChangeHandler handler)
addChangeHandler
in interface com.google.gwt.event.dom.client.HasChangeHandlers
public int getMaxLength()
ITextBox
getMaxLength
in interface ITextBox
public int getVisibleLength()
ITextBox
getVisibleLength
in interface ITextBox
public void setMaxLength(int length)
ITextBox
setMaxLength
in interface ITextBox
length
- the maximum length, in characterspublic void setVisibleLength(int length)
ITextBox
setVisibleLength
in interface ITextBox
length
- the number of visible characterspublic T asTextBoxBase()
asTextBoxBase
in interface IsTextBoxBase<T extends com.google.gwt.user.client.ui.TextBoxBase>
public void cancelKey()
IsValueBoxBase
cancelKey
in interface IsValueBoxBase<String>
public int getCursorPos()
IsValueBoxBase
getCursorPos
in interface IsValueBoxBase<String>
public String getSelectedText()
IsValueBoxBase
getSelectedText
in interface IsValueBoxBase<String>
public int getSelectionLength()
IsValueBoxBase
getSelectionLength
in interface IsValueBoxBase<String>
public String getValueOrThrow() throws ParseException
IsValueBoxBase
getValueOrThrow
in interface IsValueBoxBase<String>
ParseException
- if the value cannot be parsedpublic boolean isReadOnly()
IsValueBoxBase
isReadOnly
in interface IsValueBoxBase<String>
true
if the widget is currently read-only,
false
if the widget is currently editablepublic void selectAll()
IsValueBoxBase
selectAll
in interface IsValueBoxBase<String>
public void setAlignment(com.google.gwt.user.client.ui.ValueBoxBase.TextAlignment align)
setAlignment
in interface IsValueBoxBase<String>
align
- defines how the text should be horizontally anchoredpublic void setCursorPos(int pos)
IsValueBoxBase
setCursorPos
in interface IsValueBoxBase<String>
pos
- the new cursor positionpublic void setReadOnly(boolean readOnly)
IsValueBoxBase
setReadOnly
in interface IsValueBoxBase<String>
readOnly
- if true
, the widget becomes read-only; if
false
the widget becomes editablepublic void setSelectionRange(int pos, int length)
IsValueBoxBase
setSelectionRange
in interface IsValueBoxBase<String>
pos
- the position of the first character to be selectedlength
- the number of characters to be selectedprotected final com.google.gwt.user.client.ui.Label getLabel()
TextfieldBase
contains a Label
under the hood to
display the hint inside the text box when it is empty.protected final void onLoad()
onLoad
in class com.google.gwt.user.client.ui.Widget
public void onBrowserEvent(com.google.gwt.user.client.Event event)
onBrowserEvent
in interface com.google.gwt.user.client.EventListener
onBrowserEvent
in class com.google.gwt.user.client.ui.Widget
public void upgrade()
IUpgrade
public boolean isUpgraded()
isUpgraded
in interface IUpgrade
Copyright © 2016 com.github.ilyes4j. All rights reserved.