A standard dialog for confirmation or to get simple user input. More...
#include <Wt/Ext/MessageBox>
Inherits Wt::Ext::Dialog.
Inherited by Wt::Ext::ProgressDialog.
Public Member Functions | |
MessageBox (bool i18n=false) | |
Create an empty message box. | |
MessageBox (const WString &caption, const WString &text, Icon icon, WFlags< StandardButton > buttons, bool i18n=false) | |
Create a message box with given caption, text, icon, and buttons. | |
void | setText (const WString &text) |
Set the text for the message box. | |
const WString & | text () const |
Get the message box text. | |
void | setIcon (Icon icon) |
Set the icon. | |
Icon | icon () const |
Get the icon. | |
void | setButtons (WFlags< StandardButton > buttons) |
Set standard buttons for the message box. | |
WFlags< StandardButton > | buttons () const |
Get the standard buttons. | |
StandardButton | result () |
Get the result of this message box. | |
void | enablePrompt (bool enable) |
Show a single-line input field. | |
bool | hasPrompt () const |
Return if the messagebox may show a prompt. | |
void | enableTextArea (bool enable) |
Show a multi-line input field. | |
bool | hasTextArea () const |
Return if the messagebox may show a prompt. | |
void | setValue (const WString &value) |
Set the value in the input field. | |
const WString & | value () const |
Get the value of the input field. | |
Signal< StandardButton > & | buttonClicked () |
Signal emitted when a button is clicked. | |
virtual void | setHidden (bool hidden) |
Show or hide the message box. | |
virtual void | refresh () |
Refresh the widget. | |
Static Public Member Functions | |
static StandardButton | show (const WString &caption, const WString &text, WFlags< StandardButton > buttons, bool i18n=false) |
Convenience method to show a message box, blocking the current thread. | |
static StandardButton | prompt (const WString &caption, const WString &text, WString &value, bool multiLine=false, bool i18n=false) |
Convenience method to show a message box prompting for input, blocking the current thread. |
A standard dialog for confirmation or to get simple user input.
The message box shows a message in a dialog window, with a number of buttons. These buttons may only be standard buttons.
There are two distinct ways for using a MessageBox, which reflect the two ways of dealing with a Dialog box.
The easiest way is using the static show() method, which shows a message box, blocks the current thread, and returns the button that was pressed by the user. Since this uses the Dialog::exec(), it suffers from the same scalability issues.
The more elaborate way is by creating a MessageBox, and connecting the buttonClicked signal to a method. This method then interpretes the result and deletes the message box.
The API is slightly different from the WMessageBox API:
Example of a MessageBox
Wt::Ext::MessageBox::MessageBox | ( | bool | i18n = false |
) |
Create an empty message box.
The button labels may be set fixed English (if i18n = false), or fetched from a resource bundle if i18n = true. In that case, the key for each button is exactly the same as the English text.
Wt::Ext::MessageBox::MessageBox | ( | const WString & | caption, | |
const WString & | text, | |||
Icon | icon, | |||
WFlags< StandardButton > | buttons, | |||
bool | i18n = false | |||
) |
Create a message box with given caption, text, icon, and buttons.
The button labels may be set fixed English (if i18n = false), or fetched from a resource bundle if i18n = true. In that case, the key for each button is exactly the same as the English text.
void Wt::Ext::MessageBox::enablePrompt | ( | bool | enable | ) |
Show a single-line input field.
A message box may contain either a prompt, or a text area field, but not both. The value may be set using setValue() and retrieved using value().
void Wt::Ext::MessageBox::enableTextArea | ( | bool | enable | ) |
Show a multi-line input field.
A message box may contain either a prompt, or a text area field, but not both. The value may be set using setValue() and retrieved using value().
bool Wt::Ext::MessageBox::hasPrompt | ( | ) | const [inline] |
Return if the messagebox may show a prompt.
bool Wt::Ext::MessageBox::hasTextArea | ( | ) | const [inline] |
Return if the messagebox may show a prompt.
StandardButton Wt::Ext::MessageBox::prompt | ( | const WString & | caption, | |
const WString & | text, | |||
WString & | value, | |||
bool | multiLine = false , |
|||
bool | i18n = false | |||
) | [static] |
Convenience method to show a message box prompting for input, blocking the current thread.
Show a message box that prompts for input, blocking the current thread until the message box is closed, and return the result.
When the user confirmed message box, the value is updated with the edited value.
void Wt::Ext::MessageBox::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::Ext::Panel.
StandardButton Wt::Ext::MessageBox::result | ( | ) | [inline] |
Get the result of this message box.
This value is only defined after a button has been clicked.
void Wt::Ext::MessageBox::setValue | ( | const WString & | value | ) |
Set the value in the input field.
StandardButton Wt::Ext::MessageBox::show | ( | const WString & | caption, | |
const WString & | text, | |||
WFlags< StandardButton > | buttons, | |||
bool | i18n = false | |||
) | [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.
const WString& Wt::Ext::MessageBox::value | ( | ) | const [inline] |
Get the value of the input field.
Reimplemented in Wt::Ext::ProgressDialog.