A widget that provides in-place-editable text. More...
#include <Wt/WInPlaceEdit>

Public Member Functions | |
| WInPlaceEdit (WContainerWidget *parent=0) | |
| Creates an in-place edit. | |
| WInPlaceEdit (const WString &text, WContainerWidget *parent=0) | |
| Creates an in-place edit with the given text. | |
| WInPlaceEdit (bool buttons, const WString &text, WContainerWidget *parent=0) | |
| Creates an in-place edit with the given text. | |
| const WString & | text () const |
| Returns the current value. | |
| void | setText (const WString &text) |
| Sets the current value. | |
| void | setEmptyText (const WString &emptyText) |
| Sets the placeholder text (deprecated). | |
| const WString & | emptyText () const |
| Returns the placeholder text (deprecated). | |
| void | setPlaceholderText (const WString &placeholder) |
| Sets the placeholder text. | |
| const WString & | placeholderText () const |
| Returns the placeholder text. | |
| WLineEdit * | lineEdit () const |
| Returns the line edit. | |
| WText * | textWidget () const |
| Returns the WText widget that renders the current string. | |
| WPushButton * | saveButton () const |
| Returns the save button. | |
| WPushButton * | cancelButton () const |
| Returns the cancel button. | |
| Signal< WString > & | valueChanged () |
| Signal emitted when the value has been changed. | |
| void | setButtonsEnabled (bool enabled=true) |
| Displays the Save and 'Cancel' button during editing. | |
Protected Member Functions | |
| virtual void | render (WFlags< RenderFlag > flags) |
| Renders the widget. | |
A widget that provides in-place-editable text.
The WInPlaceEdit provides a text that may be edited in place by the user by clicking on it. When clicked, the text turns into a line edit, with optionally a save and cancel button (see setButtonsEnabled()).
When the user saves the edit, the valueChanged() signal is emitted.
Usage example:
Wt::WContainerWidget *w = new Wt::WContainerWidget(); new Wt::WText("Name: ", w); Wt::WInPlaceEdit *edit = new Wt::WInPlaceEdit("Bob Smith", w); edit->setStyleClass("inplace");
This code will produce an edit that looks like:
When the text is clicked, the edit will expand to become:
A WInPlaceEdit widget renders as a <span> containing a WText, a WLineEdit and optional buttons (WPushButton). All these widgets may be styled as such. It does not provide style information.
In particular, you may want to provide a visual indication that the text is editable e.g. using a hover effect:
CSS stylesheet:
.inplace span:hover {
background-color: gray;
}
| Wt::WInPlaceEdit::WInPlaceEdit | ( | bool | buttons, |
| const WString & | text, | ||
| WContainerWidget * | parent = 0 |
||
| ) |
Creates an in-place edit with the given text.
The first parameter configures whether buttons are available in edit mode.
| WPushButton* Wt::WInPlaceEdit::cancelButton | ( | ) | const |
Returns the cancel button.
This method returns 0 if the buttons were disabled.
| const WString& Wt::WInPlaceEdit::emptyText | ( | ) | const |
Returns the placeholder text (deprecated).
| WLineEdit* Wt::WInPlaceEdit::lineEdit | ( | ) | const |
Returns the line edit.
You may use this for example to set a validator on the line edit.
| const WString & Wt::WInPlaceEdit::placeholderText | ( | ) | const |
Returns the placeholder text.
| void Wt::WInPlaceEdit::render | ( | WFlags< RenderFlag > | flags | ) | [protected, virtual] |
Renders the widget.
This function renders the widget (or an update for the widget), after this has been scheduled using scheduleRender().
The default implementation will render the widget by serializing changes to JavaScript and HTML. You may want to reimplement this widget if you have been postponing some of the layout / rendering implementation until the latest moment possible. In that case you should make sure you call the base implementation however.
Reimplemented from Wt::WCompositeWidget.
| WPushButton* Wt::WInPlaceEdit::saveButton | ( | ) | const |
Returns the save button.
This method returns 0 if the buttons were disabled.
| void Wt::WInPlaceEdit::setButtonsEnabled | ( | bool | enabled = true | ) |
Displays the Save and 'Cancel' button during editing.
By default, the Save and Cancel buttons are shown. Call this function with enabled = false to only show a line edit.
In this mode, the enter key or any event that causes focus to be lost saves the value while the escape key cancels the editing.
| void Wt::WInPlaceEdit::setEmptyText | ( | const WString & | emptyText | ) |
Sets the placeholder text (deprecated).
| void Wt::WInPlaceEdit::setPlaceholderText | ( | const WString & | placeholder | ) |
Sets the placeholder text.
This sets the text that is shown when the field is empty.
| void Wt::WInPlaceEdit::setText | ( | const WString & | text | ) |
Sets the current value.
| const WString & Wt::WInPlaceEdit::text | ( | ) | const |
Returns the current value.
| WText* Wt::WInPlaceEdit::textWidget | ( | ) | const |
Returns the WText widget that renders the current string.
You may use this for example to set the text format of the displayed string.
Signal emitted when the value has been changed.
The signal argument provides the new value.
1.7.6.1