|
Wt
3.3.0
|
A standard dialog for confirmation or to get simple user input. More...
#include <Wt/WMessageBox>

Public Member Functions | |
| WMessageBox (WObject *parent=0) | |
| Creates an empty message box. | |
| WMessageBox (const WString &caption, const WString &text, Icon icon, WFlags< StandardButton > buttons, WObject *parent=0) | |
| Creates a message box with given caption, text, icon, and buttons. | |
| void | setText (const WString &text) |
| Sets the text for the message box. | |
| const WString & | text () const |
| Returns the message box text. | |
| WText * | textWidget () const |
| Returns the text widget. | |
| void | setIcon (Icon icon) |
| Sets the icon. | |
| Icon | icon () const |
| Returns the icon. | |
| WPushButton * | addButton (const WString &text, StandardButton result) |
| Add a custom button with given text. | |
| void | setButtons (WFlags< StandardButton > buttons) |
| Sets standard buttons for the message box. | |
| WFlags< StandardButton > | buttons () const |
| Returns the standard buttons. | |
| WPushButton * | button (StandardButton b) |
| Returns the button widget for the given standard button. | |
| StandardButton | buttonResult () |
| Returns the result of this message box. | |
| Signal< StandardButton > & | buttonClicked () |
| Signal emitted when a button is clicked. | |
Static Public Member Functions | |
| static StandardButton | show (const WString &caption, const WString &text, WFlags< StandardButton > buttons, const WAnimation &animation=WAnimation()) |
| Convenience method to show a message box, blocking the current thread. | |
A standard dialog for confirmation or to get simple user input.
The messagebox shows a message in a dialog window, with a number of buttons. These buttons may be standard buttons, or customized.
A messagebox is (usually) modal, and can be instantiated synchronously or asynchronously.
When using a messagebox asynchronously, there is no API call that waits for the messagebox to be processed. Then, the usage is similar to instantiating a WDialog (or any other widget). You need to connect to the buttonClicked signal with a method that interpretes the result and deletes the message box.
The synchronous use of a messagebox involves the use of the static show() method, which blocks the current thread until the user has processed the messabebox. Since this uses the WDialog::exec(), it suffers from the same scalability issues. See documentation of WDialog for more details.
Example code (using the exec() method, not recommended):
StandardButton result = WMessageBox::show("Confirm", "About to wreak havoc... Continue ?", Ok | Cancel);
This will show a message box that looks like this:
Example of a WMessageBox (default) |
Example of a WMessageBox (polished) |
The strings used in the WMessageBox buttons can be translated by overriding the default values for the following localization keys:
| WPushButton * Wt::WMessageBox::addButton | ( | const WString & | text, |
| StandardButton | result | ||
| ) |
Add a custom button with given text.
When the button is clicked, the associated result will be returned.
| WPushButton * Wt::WMessageBox::button | ( | StandardButton | b | ) |
Returns the button widget for the given standard button.
This may be useful to customize the style or layout of the button.
| StandardButton Wt::WMessageBox::buttonResult | ( | ) |
Returns the result of this message box.
This value is only defined after a button has been clicked.
| StandardButton Wt::WMessageBox::show | ( | const WString & | caption, |
| const WString & | text, | ||
| WFlags< StandardButton > | buttons, | ||
| const WAnimation & | animation = WAnimation() |
||
| ) | [static] |
Convenience method to show a message box, blocking the current thread.
Show a message box, blocking the current thread until the message box is closed, and return the result. The use of this method is not recommended since it uses WDialog::exec(). See documentation of WDialog for detailed information.
| WText* Wt::WMessageBox::textWidget | ( | ) | const |
Returns the text widget.
This may be useful to customize the style or layout of the displayed text.
1.7.5.1