eu.webtoolkit.jwt
Class WLineEdit

java.lang.Object
  extended by eu.webtoolkit.jwt.WObject
      extended by eu.webtoolkit.jwt.WWidget
          extended by eu.webtoolkit.jwt.WWebWidget
              extended by eu.webtoolkit.jwt.WInteractWidget
                  extended by eu.webtoolkit.jwt.WFormWidget
                      extended by eu.webtoolkit.jwt.WLineEdit
Direct Known Subclasses:
WAbstractSpinBox

public class WLineEdit
extends WFormWidget

A widget that provides a single line edit.

To act upon text changes, connect a slot to the WFormWidget#changed() signal. This signal is emitted when the user changed the content, and subsequently removes the focus from the line edit.

To act upon editing, connect a slot to the WInteractWidget#keyWentUp() signal.

At all times, the current content may be accessed with the getText() method.

You may specify a maximum length for the input using setMaxLength(). If you wish to provide more detailed input validation, you may set a validator using the WFormWidget#setValidator() method. Validators provide, in general, both client-side validation (as visual feed-back only) and server-side validation when calling WFormWidget#validate().

The widget corresponds to the HTML <input type="text"> or <input type="password"> tag.

WLineEdit is an inline widget.

CSS

The emptyText style can be configured via .Wt-edit-emptyText, other styling can be done using inline or external CSS as appropriate.

See Also:
WTextArea

Nested Class Summary
static class WLineEdit.EchoMode
          Enumeration that describes how the contents is displayed.
 
Constructor Summary
WLineEdit()
          Creates a line edit with empty content and optional parent.
WLineEdit(java.lang.String text)
          Creates a line edit with given content and optional parent.
WLineEdit(java.lang.String text, WContainerWidget parent)
          Creates a line edit with given content and optional parent.
WLineEdit(WContainerWidget parent)
          Creates a line edit with empty content and optional parent.
 
Method Summary
protected  int boxBorder(Orientation orientation)
          Returns the widget's built-in border width.
protected  int boxPadding(Orientation orientation)
          Returns the widget's built-in padding.
 int getCursorPosition()
          Returns the current cursor position.
 WLineEdit.EchoMode getEchoMode()
          Returns the echo mode.
 int getMaxLength()
          Returns the maximum length of text that can be entered.
 java.lang.String getSelectedText()
          Returns the currently selected text.
 int getSelectionStart()
          Returns the current selection start.
 java.lang.String getText()
          Returns the current content.
 int getTextSize()
          Returns the current width of the line edit in number of characters.
 java.lang.String getValueText()
          Returns the current value.
 boolean hasSelectedText()
          Returns whether there is selected text.
 void setEchoMode(WLineEdit.EchoMode echoMode)
          Sets the echo mode.
 void setMaxLength(int chars)
          Specifies the maximum length of text that can be entered.
 void setText(java.lang.String text)
          Sets the content of the line edit.
 void setTextSize(int chars)
          Specifies the width of the line edit in number of characters.
 void setValueText(java.lang.String value)
          Sets the current value.
 
Methods inherited from class eu.webtoolkit.jwt.WFormWidget
blurred, changed, enableAjax, focussed, getEmptyText, getLabel, getTabIndex, getValidator, hasFocus, isReadOnly, propagateSetEnabled, refresh, remove, render, selected, setEmptyText, setEnabled, setFocus, setFocus, setHidden, setReadOnly, setTabIndex, setValidator, validate, validated
 
Methods inherited from class eu.webtoolkit.jwt.WInteractWidget
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, setDraggable, setDraggable, setDraggable, setDraggable, touchEnded, touchMoved, touchStarted
 
Methods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, callJavaScriptMember, childrenChanged, doJavaScript, domCanBeSaved, escapeText, escapeText, escapeText, escapeText, find, getAttributeValue, getChildren, getClearSides, getDecorationStyle, getFloatSide, getHeight, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getStyleClass, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isVisible, jsStringLiteral, jsStringLiteral, removeScript, removeStyleClass, resize, setAttributeValue, setClearSides, setDecorationStyle, setDisabled, setFloatSide, setHiddenKeepsGeometry, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setOffsets, setPopup, setPositionScheme, setSelectable, setStyleClass, setToolTip, setVerticalAlignment, updateSignalConnection
 
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addStyleClass, animateHide, animateShow, containsExposed, disable, dropEvent, enable, getDrop, getJsRef, getParent, hide, htmlText, isLayoutSizeAware, layoutSizeChanged, positionAt, positionAt, removeStyleClass, resize, setClearSides, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
 
Methods inherited from class eu.webtoolkit.jwt.WObject
addChild, getObjectName, setObjectName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WLineEdit

public WLineEdit(WContainerWidget parent)
Creates a line edit with empty content and optional parent.


WLineEdit

public WLineEdit()
Creates a line edit with empty content and optional parent.

Calls this((WContainerWidget)null)


WLineEdit

public WLineEdit(java.lang.String text,
                 WContainerWidget parent)
Creates a line edit with given content and optional parent.


WLineEdit

public WLineEdit(java.lang.String text)
Creates a line edit with given content and optional parent.

Calls this(text, (WContainerWidget)null)

Method Detail

setTextSize

public void setTextSize(int chars)
Specifies the width of the line edit in number of characters.

This specifies the width of the line edit that is roughly equivalent with chars characters. This does not limit the maximum length of a string that may be entered, which may be set using setMaxLength().

The default value is 10.


getTextSize

public int getTextSize()
Returns the current width of the line edit in number of characters.

See Also:
setTextSize(int chars)

setText

public void setText(java.lang.String text)
Sets the content of the line edit.

The default value is "".

See Also:
getText()

getText

public java.lang.String getText()
Returns the current content.

See Also:
setText(String text)

setMaxLength

public void setMaxLength(int chars)
Specifies the maximum length of text that can be entered.

A value <= 0 indicates that there is no limit.

The default value is -1.


getMaxLength

public int getMaxLength()
Returns the maximum length of text that can be entered.

See Also:
setMaxLength(int chars)

setEchoMode

public void setEchoMode(WLineEdit.EchoMode echoMode)
Sets the echo mode.

The default echo mode is Normal.


getEchoMode

public WLineEdit.EchoMode getEchoMode()
Returns the echo mode.

See Also:
setEchoMode(WLineEdit.EchoMode echoMode)

getSelectionStart

public int getSelectionStart()
Returns the current selection start.

Returns -1 if there is no selected text.

See Also:
hasSelectedText(), getSelectedText()

getSelectedText

public java.lang.String getSelectedText()
Returns the currently selected text.

Returns an empty string if there is currently no selected text.

See Also:
hasSelectedText()

hasSelectedText

public boolean hasSelectedText()
Returns whether there is selected text.


getCursorPosition

public int getCursorPosition()
Returns the current cursor position.

Returns -1 if the widget does not have the focus.


getValueText

public java.lang.String getValueText()
Returns the current value.

Returns getText().

Specified by:
getValueText in class WFormWidget

setValueText

public void setValueText(java.lang.String value)
Sets the current value.

Calls setText().

Specified by:
setValueText in class WFormWidget

boxPadding

protected int boxPadding(Orientation orientation)
Description copied from class: WWidget
Returns the widget's built-in padding.

This is used by the layout managers to correct for a built-in padding which interferes with setting a widget's width (or height) to 100%.

A layout manager needs to set the width to 100% only for form widgets ( WTextArea, WLineEdit, WComboBox, etc...). Therefore, only for those widgets this needs to return the padding (the default implementation returns 0).

For form widgets, the padding depends on the specific browser/platform combination, unless an explicit padding is set for the widget.

When setting an explicit padding for the widget using a style class, you will want to reimplement this method to return this padding in case you want to set the widget inside a layout manager.

Overrides:
boxPadding in class WWidget
See Also:
WWidget.boxBorder(Orientation orientation)

boxBorder

protected int boxBorder(Orientation orientation)
Description copied from class: WWidget
Returns the widget's built-in border width.

This is used by the layout managers to correct for a built-in border which interferes with setting a widget's width (or height) to 100%.

A layout manager needs to set the width to 100% only for form widgets ( WTextArea, WLineEdit, WComboBox, etc...). Therefore, only for those widgets this needs to return the border width (the default implementation returns 0).

For form widgets, the border width depends on the specific browser/platform combination, unless an explicit border is set for the widget.

When setting an explicit border for the widget using a style class, you will want to reimplement this method to return this border width, in case you want to set the widget inside a layout manager.

Overrides:
boxBorder in class WWidget
See Also:
WWidget.boxPadding(Orientation orientation)