#include <Wt/WInPlaceEdit>

Public Member Functions | |
| WInPlaceEdit (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 empty text to be shown when the field is empty and not editable. | |
| const WString & | emptyText () |
| Returns the empty text to be shown when the field is empty and not editable. | |
| WLineEdit * | lineEdit () const |
| Returns the line edit. | |
| 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. | |
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:
WInPlaceEdit text mode
WInPlaceEdit edit mode
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;
}
| void Wt::WInPlaceEdit::setEmptyText | ( | const WString & | emptyText | ) |
| const WString & Wt::WInPlaceEdit::emptyText | ( | ) |
Returns the empty text to be shown when the field is empty and not editable.
| WLineEdit* Wt::WInPlaceEdit::lineEdit | ( | ) | const [inline] |
Returns the line edit.
You may use this for example to set a validator on the line edit.
| WPushButton* Wt::WInPlaceEdit::saveButton | ( | ) | const [inline] |
Returns the save button.
This method returns 0 if the buttons were disabled.
| WPushButton* Wt::WInPlaceEdit::cancelButton | ( | ) | const [inline] |
Returns the cancel button.
This method returns 0 if the buttons were disabled.
Signal emitted when the value has been changed.
The signal argument provides the new value.
| 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 has the effect of the save button and the escape key has the effect of the cancel button.
1.5.6