Wt examples
4.9.2
|
A JavaScript based popup window, encapsulating the Javascript functions alert(), confirm(), and prompt(). More...
#include <Popup.h>
Public Types | |
enum | Type { Confirm , Alert , Prompt } |
Popup type. More... | |
Public Member Functions | |
Popup (Type t, const WString &message, const std::string defaultValue) | |
Popup constructor. | |
void | setMessage (const WString &message) |
Change the message. | |
void | setDefaultValue (const std::string defaultValue) |
Change the default value for a prompt dialog. | |
const WString & | message () const |
Get the current message. | |
const std::string & | defaultValue () const |
Get the default value for a prompt dialog. | |
JSignal< std::string > & | okPressed () |
Signal emitted when ok pressed. | |
JSignal & | cancelPressed () |
Signal emitted when cancel is pressed. | |
Static Public Member Functions | |
static std::unique_ptr< Popup > | createConfirm (const WString &message) |
Create a confirm dialog. | |
static std::unique_ptr< Popup > | createPrompt (const WString &message, const std::string defaultValue) |
Create a prompt dialog with the given default value. | |
static std::unique_ptr< Popup > | createAlert (const WString &message) |
Create an alert dialog. | |
Public Attributes | |
JSlot | show |
Show the dialog. | |
Private Member Functions | |
void | setJavaScript () |
Update the javascript code. | |
Private Attributes | |
JSignal< std::string > | okPressed_ |
JSignal | cancelPressed_ |
Type | t_ |
WString | message_ |
std::string | defaultValue_ |
A JavaScript based popup window, encapsulating the Javascript functions alert(), confirm(), and prompt().
Use one of the create static methods to create a popup. This will not display the popup, until either the show slot is triggered from an event handler, or is executed using it's exec() method.
When the user closes the popup, either the okPressed or cancelPressed signal is emitted. For a prompt dialog, the value is passed as a parameter to the okPressed signal.
enum Popup::Type |
Popup::Popup | ( | Type | t, |
const WString & | message, | ||
const std::string | defaultValue | ||
) |
Popup constructor.
Definition at line 14 of file Popup.C.
|
inline |
|
static |
Create an alert dialog.
|
static |
Create a confirm dialog.
|
static |
Create a prompt dialog with the given default value.
|
inline |
|
inline |
|
inline |
void Popup::setDefaultValue | ( | const std::string | defaultValue | ) |
Change the default value for a prompt dialog.
|
private |
Update the javascript code.
Definition at line 25 of file Popup.C.
void Popup::setMessage | ( | const WString & | message | ) |
Change the message.
JSlot Popup::show |