Class WTextArea

Direct Known Subclasses:
WTextEdit

public class WTextArea extends WFormWidget
A widget that provides a multi-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.

WTextArea is an inline widget.

CSS

The widget corresponds to an HTML <textarea> tag can be styled using inline or external CSS as appropriate. The emptyText style can be configured via .Wt-edit-emptyText.

See Also:
  • Constructor Details

  • Method Details

    • setColumns

      public void setColumns(int columns)
      Sets the number of columns.

      The default value is 20.

    • setRows

      public void setRows(int rows)
      Sets the number of rows.

      The default value is 5.

    • getColumns

      public int getColumns()
      Returns the number of columns.

      See Also:
    • getRows

      public int getRows()
      Returns the number of rows.

      See Also:
    • getText

      public String getText()
      Returns the current content.
    • setText

      public void setText(String text)
      Sets the content of the text area.

      The default text is "".

    • getSelectionStart

      public int getSelectionStart()
      Returns the current selection start.

      Returns -1 if there is no selected text.

      See Also:
    • getSelectedText

      public String getSelectedText()
      Returns the currently selected text.

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

      See Also:
    • 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 String getValueText()
      Returns the current value.

      Returns getText().

      Specified by:
      getValueText in class WFormWidget
    • setValueText

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

      Calls setText().

      Specified by:
      setValueText in class WFormWidget
    • textInput

      public EventSignal textInput()
      Event signal emitted when the text in the input field changed.

      This signal is emitted whenever the text contents has changed. Unlike the WFormWidget.changed() signal, the signal is fired on every change, not only when the focus is lost. Unlike the WInteractWidget.keyPressed() signal, this signal is fired also for other events that change the text, such as paste actions.

      See Also:
    • setFormData

      protected void setFormData(WObject.FormData formData)
      Overrides:
      setFormData in class WObject
    • 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:
    • 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: