Wt examples
4.2.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. More... | |
void | setMessage (const WString &message) |
Change the message. More... | |
void | setDefaultValue (const std::string defaultValue) |
Change the default value for a prompt dialog. More... | |
const WString & | message () const |
Get the current message. More... | |
const std::string & | defaultValue () const |
Get the default value for a prompt dialog. More... | |
JSignal< std::string > & | okPressed () |
Signal emitted when ok pressed. More... | |
JSignal & | cancelPressed () |
Signal emitted when cancel is pressed. More... | |
Static Public Member Functions | |
static std::unique_ptr< Popup > | createConfirm (const WString &message) |
Create a confirm dialog. More... | |
static std::unique_ptr< Popup > | createPrompt (const WString &message, const std::string defaultValue) |
Create a prompt dialog with the given default value. More... | |
static std::unique_ptr< Popup > | createAlert (const WString &message) |
Create an alert dialog. More... | |
Public Attributes | |
JSlot | show |
Show the dialog. More... | |
Private Member Functions | |
void | setJavaScript () |
Update the javascript code. More... | |
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 type.
Enumerator | |
---|---|
Confirm | |
Alert | |
Prompt |
Popup::Popup | ( | Type | t, |
const WString & | message, | ||
const std::string | defaultValue | ||
) |
Popup constructor.
Definition at line 14 of file Popup.C.
|
inline |
|
static |
|
static |
|
static |
Create a prompt dialog with the given default value.
Definition at line 83 of file Popup.C.
|
inline |
|
inline |
|
inline |
void Popup::setDefaultValue | ( | const std::string | defaultValue | ) |
Change the default value for a prompt dialog.
Definition at line 67 of file Popup.C.
|
private |
Update the javascript code.
void Popup::setMessage | ( | const WString & | message | ) |
JSlot Popup::show |