Wt  3.3.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Protected 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.
 WPushButton (const WString &text, TextFormat textFormat, WContainerWidget *parent=0)
 Creates a push button with given label text.
void setDefault (bool enabled)
 Sets the default property.
bool isDefault () const
 Returns whether the button is a default button.
void setCheckable (bool checkable)
 Sets whether the button is checkable.
bool isCheckable () const
 Returns whether a button is checkable.
void setChecked (bool checked)
 Sets the button state.
void setChecked ()
 Checks the button.
void setUnChecked ()
 Unchecks the button.
bool isChecked () const
 Returns the button state.
bool setText (const WString &text)
 Sets the button text.
const WStringtext () const
 Returns the button text.
bool setTextFormat (TextFormat format)
 Sets the text format.
TextFormat textFormat () const
 Returns the text format.
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.
void setMenu (WPopupMenu *menu)
 Links a popup menu to the button.
WPopupMenumenu () const
 Returns an associated popup menu.
virtual void refresh ()
 Refresh the widget.
EventSignalchecked ()
 Signal emitted when the button gets checked.
EventSignalunChecked ()
 Signal emitted when the button gets unchecked.
virtual bool setFirstFocus ()
 Set focus on the widget's first descendant.

Protected Member Functions

virtual void propagateSetEnabled (bool enabled)
 Propagates that a widget was enabled or disabled through children.
virtual void enableAjax ()
 Progresses to an Ajax-enabled 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 (with some exceptions in the bootstrap theme).


Constructor & Destructor Documentation

Wt::WPushButton::WPushButton ( const WString text,
WContainerWidget parent = 0 
)

Creates a push button with given label text.

The default text format is PlainText.


Member Function Documentation

Signal emitted when the button gets checked.

This signal is emitted when the user checks the button.

You can use the clicked() signal to react to any change of the button state.

See also:
setCheckable()
void Wt::WPushButton::enableAjax ( ) [protected, virtual]

Progresses to an Ajax-enabled widget.

This method is called when the progressive bootstrap method is used, and support for AJAX has been detected. The default behavior will upgrade the widget's event handling to use AJAX instead of full page reloads, and propagate the call to its children.

You may want to reimplement this method if you want to make changes to widget when AJAX is enabled. You should always call the base implementation.

See also:
WApplication::enableAjax()

Reimplemented from Wt::WFormWidget.

Returns the icon.

See also:
setIcon()

Returns whether a button is checkable.

See also:
setCheckable()

Returns the button state.

See also:
setChecked()

Returns whether the button is a default button.

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

Returns the destination link.

See also:
setLink()

Returns the location where the linked content should be displayed.

See also:
setLinkTarget()

Returns an associated popup menu.

See also:
setMenu()
void Wt::WPushButton::propagateSetEnabled ( bool  enabled) [protected, virtual]

Propagates that a widget was enabled or disabled through children.

When enabling or disabling a widget, you usually also want to disable contained children. This method is called by setDisabled() to propagate its state to all children.

You may want to reimplement this method if they wish to render differently when a widget is disabled. The default implementation will propagate the signal to all children.

Reimplemented from Wt::WFormWidget.

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.

Note:
This does *not* rerender the widget! Calling refresh() usually does not have any effect (unless you've reimplemented refresh() to attach to it an effect).

Reimplemented from Wt::WFormWidget.

Returns the destination resource (deprecated).

Returns 0 if no resource has been set.

See also:
setResource()
Deprecated:
Use link() instead.
void Wt::WPushButton::setCheckable ( bool  checkable)

Sets whether the button is checkable.

A checkable button can be checked and unchecked, and clicking will toggle between these two states.

See also:
setChecked(bool)
void Wt::WPushButton::setChecked ( bool  checked)

Sets the button state.

This is ignored for a button which is not checkable.

This method does not emit one of the checked() or unChecked() signals.

See also:
setCheckable(), setChecked(), setUnChecked()

Checks the button.

Does not emit the checked() signal.

See also:
setChecked(bool)
void Wt::WPushButton::setDefault ( bool  enabled)

Sets the default property.

This has only a functional meaning for a button in a dialog footer, as it becomes associated with pressing 'enter' in the dialog.

A default button may be rendered in a different style, depending on the theme.

bool Wt::WPushButton::setFirstFocus ( ) [virtual]

Set focus on the widget's first descendant.

Set focus on the widget itself, or on a first descendant which can receive focus.

Returns whether focus could be set.

Reimplemented from Wt::WWebWidget.

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.

Warning:
In Bootstrap theme, you should set a link before it's rendered since it commit's the button to be rendered as an anchor. (see also http://redmine.emweb.be/issues/1802).

Sets the link target.

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

Links a popup menu to the button.

When the button is clicked, the linked popup menu is shown.

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

Sets a destination URL (deprecated).

Deprecated:
Use setLink() insteadd.

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.
bool Wt::WPushButton::setText ( const WString text)

Sets the button text.

The default text format is Wt::PlainText.

When the current text format is Wt::XHTMLText, and text is literal (not created using WString::tr()), it is parsed using an XML parser which discards malicious tags and attributes silently. When the parser encounters an XML parse error, the textFormat is changed to Wt::PlainText.

Returns whether the text could be set using the current textFormat. A return value of false indicates that the text format was changed in order to be able to accept the new text.

See also:
setTextFormat()

Sets the text format.

The textFormat controls how the string should be interpreted: either as plain text, which is displayed literally, or as XHTML-markup.

When changing the textFormat to Wt::XHTMLText, and the current text is literal (not created using WString::tr()), the current text is parsed using an XML parser which discards malicious tags and attributes silently. When the parser encounters an XML parse error, the textFormat is left unchanged, and this method returns false.

Returns whether the textFormat could be set for the current text.

The default format is Wt::PlainText.

Unchecks the button.

Does not emit the unChecked() signal.

See also:
setChecked(bool)
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()

Returns the text format.

See also:
setTextFormat()

Signal emitted when the button gets unchecked.

This signal is emitted when the user unchecks the button.

You can use the clicked() signal to react to any change of the button state.

See also:
setCheckable()
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 Functions Variables Typedefs Enumerations Enumerator

Generated on Tue Mar 22 2016 for the C++ Web Toolkit (Wt) by doxygen 1.7.6.1