Forms — widgets and support classes for capturing user information

In place edit

The WInPlaceEdit widget provides in-place-editable text. The text that may be edited in place by clicking on it.

In place edit with buttons

By default, the Save and Cancel buttons are shown. To prevent losing the widget, always use setEmptyText() in addition to setText() or initially setting the text by the constructor.

Example
This is editable text
source
#include <Wt/WContainerWidget.h>
#include <Wt/WInPlaceEdit.h>
#include <Wt/WText.h>


auto container = Wt::cpp14::make_unique<Wt::WContainerWidget>();

auto ipe =
    container->addWidget(Wt::cpp14::make_unique<Wt::WInPlaceEdit>("This is editable text"));
ipe->setPlaceholderText("Enter something");

In place edit without buttons

To show the line edit only, call setButtonsEnabled() with parameter enabled set to false; this hides the buttons. In this mode, any event that causes focus to be lost saves the value while the escape key cancels the editing.

Example
This is editable text
source
#include <Wt/WContainerWidget.h>
#include <Wt/WInPlaceEdit.h>
#include <Wt/WText.h>


auto container = Wt::cpp14::make_unique<Wt::WContainerWidget>();

Wt::WInPlaceEdit *ipe =
    container->addWidget(Wt::cpp14::make_unique<Wt::WInPlaceEdit>("This is editable text"));
ipe->setPlaceholderText("Enter something");
ipe->setButtonsEnabled(false);

Top