Wt: Wt::WTextArea Class Reference

Wt 3.3.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions
Wt::WTextArea Class Reference

A widget that provides a multi-line edit. More...

`#include <Wt/WTextArea>`

Inheritance diagram for Wt::WTextArea:
[legend]

List of all members.

## Public Member Functions
| WTextArea (WContainerWidget *parent=0)
| Creates a text area with empty content and optional parent.
| WTextArea (const WString &content, WContainerWidget *parent=0)
| Creates a text area with given content and optional parent.
void | setColumns (int cols)
| Sets the number of columns.
void | setRows (int rows)
| Sets the number of rows.
int | columns () const
| Returns the number of columns.
int | rows () const
| Returns the number of rows.
const WString & | text () const
| Returns the current content.
virtual void | setText (const WString &text)
| Sets the content of the text area.
int | selectionStart () const
| Returns the current selection start.
WString | selectedText () const
| Returns the currently selected text.
bool | hasSelectedText () const
| Returns whether there is selected text.
int | cursorPosition () const
| Returns the current cursor position.
virtual WString | valueText () const
| Returns the current value.
virtual void | setValueText (const WString &text)
| Sets the current value.
## Protected Member Functions
virtual int | boxPadding (Orientation orientation) const
| Returns the widget's built-in padding.
virtual int | boxBorder (Orientation orientation) const
| Returns the widget's built-in border width.

## Detailed Description

A widget that provides a multi-line edit.

To act upon text changes, connect a slot to the 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 keyWentUp() signal.

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

Usage example:

     Wt::WContainerWidget *w = new Wt::WContainerWidget();
     Wt::WLabel *label = new Wt::WLabel("Comments:", w);
     Wt::WTextArea *edit = new Wt::WTextArea("", w);
     label->setBuddy(edit);

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:
  WLineEdit

## Member Function Documentation

int Wt::WTextArea::boxBorder | ( | Orientation | orientation | ) | const`[protected, virtual]`

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.

See also:
  boxPadding()

Reimplemented from Wt::WWidget.

Reimplemented in Wt::WTextEdit.

int Wt::WTextArea::boxPadding | ( | Orientation | orientation | ) | const`[protected, virtual]`

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.

See also:
  boxBorder()

Reimplemented from Wt::WWidget.

Reimplemented in Wt::WTextEdit.

int Wt::WTextArea::columns | ( |  | ) | const

Returns the number of columns.

See also:
  setColumns()

int Wt::WTextArea::cursorPosition | ( |  | ) | const

Returns the current cursor position.

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

bool Wt::WTextArea::hasSelectedText | ( |  | ) | const

Returns whether there is selected text.

See also:
  selectedtext()

int Wt::WTextArea::rows | ( |  | ) | const

Returns the number of rows.

See also:
  setRows()

WString Wt::WTextArea::selectedText | ( |  | ) | const

Returns the currently selected text.

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

See also:
  hasSelectedText()

int Wt::WTextArea::selectionStart | ( |  | ) | const

Returns the current selection start.

Returns -1 if there is no selected text.

See also:
  hasSelectedText(), selectedText()

void Wt::WTextArea::setColumns | ( | int | cols | ) |

Sets the number of columns.

The default value is 20.

void Wt::WTextArea::setRows | ( | int | rows | ) |

Sets the number of rows.

The default value is 5.

void Wt::WTextArea::setText | ( | const WString & | text | ) | `[virtual]`

Sets the content of the text area.

The default text is "".

Reimplemented in Wt::WTextEdit.

void Wt::WTextArea::setValueText | ( | const WString & | text | ) | `[virtual]`

Sets the current value.

Calls setText().

Implements Wt::WFormWidget.

WString Wt::WTextArea::valueText | ( |  | ) | const`[virtual]`

Returns the current value.

Returns text().

Implements Wt::WFormWidget.

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator