Wt  3.2.3
Public Member Functions
Wt::WPushButton Class Reference

A widget that represents a push button. More...

#include <Wt/WPushButton>

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

List of all members.

Public Member Functions

 WPushButton (WContainerWidget *parent=0)
 Creates a push button.
 WPushButton (const WString &text, WContainerWidget *parent=0)
 Creates a push button with given label text.
void setText (const WString &text)
 Sets the button text.
const WStringtext () const
 Returns the button text.
void setIcon (const WLink &link)
 Sets an icon.
WLink icon () const
 Returns the icon.
void setLink (const WLink &link)
 Sets a destination link.
const WLinklink () const
 Returns the destination link.
void setRef (const std::string &url)
 Sets a destination URL (deprecated).
std::string ref () const
 Returns the destination URL (deprecated).
void setResource (WResource *resource)
 Sets a destination resource (deprecated).
WResourceresource () const
 Returns the destination resource (deprecated).
virtual WString valueText () const
 Returns the current value.
virtual void setValueText (const WString &value)
 Sets the current value.
void setLinkTarget (AnchorTarget target)
 Sets the link target.
AnchorTarget linkTarget () const
 Returns the location where the linked content should be displayed.
virtual void refresh ()
 Refresh the widget.

Detailed Description

A widget that represents a push button.

To act on a button click, connect a slot to the clicked() signal.

Usage example:

 Wt::WPushButton *ok = new Wt::WPushButton("Okay");
 ok->clicked().connect(ok, &Wt::WPushButton::disable);
 ok->clicked().connect(this, &MyClass::processData);

WPushButton is an inline widget.

CSS

The widget corresponds to the HTML <button> tag and has the Wt-btn style. It may be styled through the current theme, or you can override the style using internal or external CSS as appropriate.


Member Function Documentation

WLink Wt::WPushButton::icon ( ) const

Returns the icon.

See also:
setIcon()
const WLink& Wt::WPushButton::link ( ) const

Returns the destination link.

See also:
setLink()
AnchorTarget Wt::WPushButton::linkTarget ( ) const

Returns the location where the linked content should be displayed.

See also:
setLinkTarget()
std::string Wt::WPushButton::ref ( ) const

Returns the destination URL (deprecated).

When the button refers to a resource, the current resource URL is returned. Otherwise, the URL is returned that was set using setRef().

See also:
setRef(), WResource::url()
Deprecated:
Use link() instead.
void Wt::WPushButton::refresh ( ) [virtual]

Refresh the widget.

The refresh method is invoked when the locale is changed using WApplication::setLocale() or when the user hit the refresh button.

The widget must actualize its contents in response.

Reimplemented from Wt::WFormWidget.

WResource* Wt::WPushButton::resource ( ) const

Returns the destination resource (deprecated).

Returns 0 if no resource has been set.

See also:
setResource()
Deprecated:
Use link() instead.
void Wt::WPushButton::setIcon ( const WLink link)

Sets an icon.

The icon is placed to the left of the text.

void Wt::WPushButton::setLink ( const WLink link)

Sets a destination link.

This method can be used to make the button behave like a WAnchor (or conversely, an anchor look like a button) and redirect to another URL when clicked.

The link may be to a URL, a resource, or an internal path.

By default, a button does not link to an URL and you should listen to the clicked() signal to react to a click event.

void Wt::WPushButton::setLinkTarget ( AnchorTarget  target)

Sets the link target.

This sets the target where the linked contents should be displayed. The default target is TargetSelf.

void Wt::WPushButton::setRef ( const std::string &  url)

Sets a destination URL (deprecated).

Deprecated:
Use setLink() insteadd.
void Wt::WPushButton::setResource ( WResource resource)

Sets a destination resource (deprecated).

This method can be used to make the button behave like a WAnchor (or conversely, an anchor look like a button) and redirect to another resource when clicked.

A resource specifies application-dependent content, which may be generated by your application on demand.

This sets the resource as the destination of the button, and is an alternative to setRef(). The resource may be cleared by passing resource = 0.

The button does not assume ownership of the resource.

See also:
setRef()
Deprecated:
Use setLink() instead.
void Wt::WPushButton::setValueText ( const WString value) [virtual]

Sets the current value.

Has no effect, since a button has not value.

Implements Wt::WFormWidget.

const WString& Wt::WPushButton::text ( ) const

Returns the button text.

See also:
setText()
WString Wt::WPushButton::valueText ( ) const [virtual]

Returns the current value.

Returns an empty string, since a button has no value.

Implements Wt::WFormWidget.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator

Generated on Thu Nov 1 2012 for the C++ Web Toolkit (Wt) by doxygen 1.7.5.1