Wt  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Public Member Functions | List of all members
Wt::WInPlaceEdit Class Reference

A widget that provides in-place-editable text. More...

#include <Wt/WInPlaceEdit>

Inheritance diagram for Wt::WInPlaceEdit:
Inheritance graph
[legend]

Public Member Functions

 WInPlaceEdit (const WString &text, WContainerWidget *parent=0)
 Creates an in-place edit with the given text.
const WStringtext () 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 being edited.
const WStringemptyText ()
 Returns the empty text to be shown when the field is empty and not being edited.
WLineEditlineEdit () const
 Returns the line edit.
WTexttextWidget () const
 Returns the WText widget that renders the current string.
WPushButtonsaveButton () const
 Returns the save button.
WPushButtoncancelButton () 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.
- Public Member Functions inherited from Wt::WCompositeWidget
 WCompositeWidget (WContainerWidget *parent=0)
 Creates a WCompositeWidget.
 WCompositeWidget (WWidget *implementation, WContainerWidget *parent)
 Creates a WCompositeWidget with given implementation.
virtual const std::string id () const
 Returns the (unique) identifier for this object.
virtual void setPositionScheme (PositionScheme scheme)
 Sets the CSS position scheme.
virtual PositionScheme positionScheme () const
 Returns the CSS position scheme.
virtual void setOffsets (const WLength &offset, WFlags< Side > sides=All)
 Sets CSS offsets for a non-statically positioned widget.
virtual WLength offset (Side s) const
 Returns a CSS offset.
virtual void resize (const WLength &width, const WLength &height)
 Resizes the widget.
virtual WLength width () const
 Returns the width.
virtual WLength height () const
 Returns the height.
virtual void setMinimumSize (const WLength &width, const WLength &height)
 Sets a minimum size.
virtual WLength minimumWidth () const
 Returns the minimum width.
virtual WLength minimumHeight () const
 Returns the minimum height.
virtual void setMaximumSize (const WLength &width, const WLength &height)
 Sets a maximum size.
virtual WLength maximumWidth () const
 Returns the maximum width.
virtual WLength maximumHeight () const
 Returns the maximum height.
virtual void setLineHeight (const WLength &height)
 Sets the CSS line height for contained text.
virtual WLength lineHeight () const
 Returns the CSS line height for contained text.
virtual void setFloatSide (Side s)
 Specifies a CSS float side.
virtual Side floatSide () const
 Returns the CSS float side.
virtual void setClearSides (WFlags< Side > sides)
 Sets the sides that should be cleared of floats.
virtual WFlags< SideclearSides () const
 Returns the sides that should remain empty.
virtual void setMargin (const WLength &margin, WFlags< Side > sides=All)
 Sets CSS margins around the widget.
virtual WLength margin (Side side) const
 Returns a CSS margin set.
virtual void setHiddenKeepsGeometry (bool enabled)
 Sets whether the widget keeps its geometry when hidden.
virtual bool hiddenKeepsGeometry () const
 Returns whether the widget keeps its geometry when hidden.
virtual void setHidden (bool hidden, const WAnimation &animation=WAnimation())
 Hides or shows the widget.
virtual bool isHidden () const
 Returns whether the widget is set hidden.
virtual bool isVisible () const
 Returns whether the widget is visible.
virtual void setDisabled (bool disabled)
 Sets whether the widget is disabled.
virtual bool isDisabled () const
 Returns whether the widget is set disabled.
virtual bool isEnabled () const
 Returns whether the widget is enabled.
virtual void setPopup (bool popup)
 Lets the widget overlay over other sibling widgets.
virtual bool isPopup () const
 Returns whether the widget is overlayed.
virtual void setInline (bool isInline)
 Sets whether the widget is displayed inline or as a block.
virtual bool isInline () const
 Returns whether the widget is displayed inline or as block.
virtual void setDecorationStyle (const WCssDecorationStyle &style)
 Sets a CSS decoration style.
virtual WCssDecorationStyledecorationStyle ()
 Returns the decoration style of this widget.
virtual void setStyleClass (const WString &styleClass)
 Sets (one or more) CSS style classes.
virtual WString styleClass () const
 Returns the CSS style class.
virtual void addStyleClass (const WString &styleClass, bool force=false)
 Adds a CSS style class.
virtual void removeStyleClass (const WString &styleClass, bool force=false)
 Removes a CSS style class.
virtual void setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength::Auto)
 Sets the vertical alignment.
virtual AlignmentFlag verticalAlignment () const
 Returns the vertical alignment.
virtual WLength verticalAlignmentLength () const
 Returns the fixed vertical alignment that was set.
virtual void setToolTip (const WString &text, TextFormat textFormat=PlainText)
 Sets a tooltip.
virtual WString toolTip () const
 Returns the tooltip.
virtual void refresh ()
 Refresh the widget.
virtual void setAttributeValue (const std::string &name, const WString &value)
 Sets an attribute value.
virtual WString attributeValue (const std::string &name) const
 Returns an attribute value.
virtual void setJavaScriptMember (const std::string &name, const std::string &value)
 Sets a JavaScript member.
virtual std::string javaScriptMember (const std::string &name) const
 Returns the value of a JavaScript member.
virtual void callJavaScriptMember (const std::string &name, const std::string &args)
 Calls a JavaScript member.
virtual void load ()
 Loads content just before the widget is used.
virtual bool loaded () const
 Returns whether this widget has been loaded.
virtual void setTabIndex (int index)
 Sets the tab index.
virtual int tabIndex () const
 Returns the tab index.
virtual void setId (const std::string &id)
 Sets the CSS Id.
virtual WWidgetfind (const std::string &name)
 Finds a descendent widget by name.
virtual void setSelectable (bool selectable)
 Sets as selectable.
virtual void doJavaScript (const std::string &js)
 Executes the given JavaScript statements when the widget is rendered or updated.
virtual void propagateSetEnabled (bool enabled)
 Propagates that a widget was enabled or disabled through children.
- Public Member Functions inherited from Wt::WWidget
virtual ~WWidget ()
 Destructor.
WWidgetparent () const
 Returns the parent widget.
void setWidth (const WLength &width)
 Sets the width.
void setHeight (const WLength &height)
 Sets the height.
virtual void positionAt (const WWidget *widget, Orientation orientation=Vertical)
 Positions a widget next to another widget.
std::string jsRef () const
 Returns a JavaScript expression to the corresponding DOM node.
virtual void acceptDrops (const std::string &mimeType, const WString &hoverStyleClass=WString())
 Sets a mime type to be accepted for dropping.
virtual void stopAcceptDrops (const std::string &mimeType)
 Indicates that a mime type is no longer accepted for dropping.
virtual void htmlText (std::ostream &out)
 Streams the (X)HTML representation.
bool isRendered () const
 Returns whether the widget is rendered.
void hide ()
 Hides the widget.
void animateHide (const WAnimation &animation)
 Hides the widget using an animation.
void show ()
 Shows the widget.
void animateShow (const WAnimation &animation)
 Shows the widget using an animation.
void enable ()
 Enables the widget.
void disable ()
 Disable thes widget.
bool layoutSizeAware () const
 Returns whether the widget is layout size aware.
- Public Member Functions inherited from Wt::WObject
 WObject (WObject *parent=0)
 Create a WObject with a given parent object.
virtual ~WObject ()
 Destructor.
void setObjectName (const std::string &name)
 Sets an object name.
virtual std::string objectName () const
 Returns the object name.
void resetLearnedSlots ()
 Resets learned stateless slot implementations.
template<class T >
void resetLearnedSlot (void(T::*method)())
 Resets a learned stateless slot implementation.
template<class T >
WStatelessSlot * implementStateless (void(T::*method)())
 Declares a slot to be stateless and learn client-side behaviour on first invocation.
template<class T >
WStatelessSlot * implementStateless (void(T::*method)(), void(T::*undoMethod)())
 Declares a slot to be stateless and learn client-side behaviour in advance.
template<class T >
WStatelessSlot * implementJavaScript (void(T::*method)(), const std::string &jsCode)
 Provides a JavaScript implementation for a method.
void addChild (WObject *child)
 Adds a child object.
virtual void removeChild (WObject *child)
 Removes a child object.
const std::vector< WObject * > & children () const
 Returns the children.

Additional Inherited Members

- Public Types inherited from Wt::WObject
typedef void(WObject::* Method )()
 Typedef for a WObject method without arguments.
- Static Public Member Functions inherited from Wt::WWidget
static WString tr (const char *key)
 Short hand for WString::tr()
- Protected Member Functions inherited from Wt::WCompositeWidget
virtual void enableAjax ()
 Progresses to an Ajax-enabled widget.
void setImplementation (WWidget *widget)
 Set the implementation widget.
WWidgetimplementation ()
 Get the implementation widget.
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.
- Static Protected Member Functions inherited from Wt::WObject
static WObjectsender ()
 Returns the sender of the current slot call.

Detailed Description

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:

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-1.png
WInPlaceEdit text mode

When the text is clicked, the edit will expand to become:

WInPlaceEdit-2.png
WInPlaceEdit edit mode

CSS

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;
}

Member Function Documentation

WPushButton* Wt::WInPlaceEdit::cancelButton ( ) const

Returns the cancel button.

This method returns 0 if the buttons were disabled.

See Also
saveButton(), setButtonsEnabled()
const WString & Wt::WInPlaceEdit::emptyText ( )

Returns the empty text to be shown when the field is empty and not being edited.

See Also
setEmptyText()
WLineEdit* Wt::WInPlaceEdit::lineEdit ( ) const

Returns the line edit.

You may use this for example to set a validator on the line edit.

WPushButton* Wt::WInPlaceEdit::saveButton ( ) const

Returns the save button.

This method returns 0 if the buttons were disabled.

See Also
cancelButton(), setButtonsEnabled()
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 empty text to be shown when the field is empty and not being edited.

See Also
emptyText()
void Wt::WInPlaceEdit::setText ( const WString text)

Sets the current value.

See Also
text()
const WString & Wt::WInPlaceEdit::text ( ) const

Returns the current value.

See Also
setText()
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<WString>& Wt::WInPlaceEdit::valueChanged ( )

Signal emitted when the value has been changed.

The signal argument provides the new value.


Generated on Wed Oct 22 2014 for the C++ Web Toolkit (Wt) by doxygen 1.8.1.2