docs
Docs
C++ API
C API
Search API
Ctrl K
2.0
2.0
latest
1.4
Ultralight C++ API
2.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
Dialogs.h
Go to the documentation of this file.
1
///
2
/// Copyright (C) 2026 Ultralight, Inc. All rights reserved.
3
/// A license is required for commercial use. https://ultralig.ht
4
///
5
/// @file Dialogs.h
6
///
7
/// Native modal message boxes for alerts and confirmations.
8
///
9
/// `#include <AppCore/Dialogs.h>`
10
///
11
/// This header provides ShowMessageBox() to display modal dialogs from the host OS. The call blocks
12
/// until the user responds and returns the selected button result.
13
///
14
/// You can prompt the user for confirmation before discarding unsaved edits:
15
///
16
/// ```
17
/// bool ConfirmDiscard() {
18
/// ButtonResult result = ShowMessageBox("Discard changes?",
19
/// "Your unsaved edits will be lost.",
20
/// DialogIcon::Question, ButtonType::YesNo);
21
/// return result == ButtonResult::Yes;
22
/// }
23
/// ```
24
///
25
/// ## Main Thread and Linux Fallback
26
///
27
/// You must call ShowMessageBox() on the main thread.
28
///
29
/// On Linux, the library logs the message and returns the declining button (or ButtonResult::OK
30
/// when it's the only button) whenever it can't display a dialog:
31
///
32
/// - **The call runs on a background thread.**
33
/// - **The host system doesn't have GTK 3 installed.**
34
///
35
/// ## In-Window HTML Dialogs
36
///
37
/// To style dialogs with HTML and CSS instead of native OS chrome, create a floating panel through
38
/// Foreground. Setting FocusPolicy::Grab on the panel ensures it takes keyboard focus whenever it's
39
/// shown.
40
///
41
/// @see ShowMessageBox(), Foreground, FocusPolicy
42
///
43
44
#pragma once
45
46
#include "
Defines.h
"
47
#include <
Ultralight/String.h
>
48
49
namespace
ultralight
{
50
51
///
52
/// Enum representing the icon to be displayed in a dialog.
53
///
54
enum class
DialogIcon
{
55
Info
,
///< Information icon
56
Warning
,
///< Warning icon
57
Error
,
///< Error icon
58
Question
///< Question icon
59
};
60
61
///
62
/// Enum representing the button types in a dialog.
63
///
64
enum class
ButtonType
{
65
OK
,
///< Single "OK" button
66
OKCancel
,
///< "OK" and "Cancel" buttons
67
YesNo
///< "Yes" and "No" buttons
68
};
69
70
///
71
/// Enum representing the result of a dialog button press.
72
///
73
enum class
ButtonResult
{
74
OK
,
///< "OK" button was pressed
75
Cancel
,
///< "Cancel" button was pressed
76
Yes
,
///< "Yes" button was pressed
77
No
///< "No" button was pressed
78
};
79
80
///
81
/// Show a modal message box with the specified title, message, icon, and buttons.
82
///
83
/// @param title The title of the message box.
84
///
85
/// @param message The message to display in the message box.
86
///
87
/// @param icon The icon to display in the message box (default: DialogIcon::Info).
88
///
89
/// @param buttons The button type to display in the message box (default: ButtonType::OK).
90
///
91
/// @return Returns the result of the button press.
92
///
93
AExport
ButtonResult
ShowMessageBox
(
const
String
& title,
const
String
& message,
94
DialogIcon
icon =
DialogIcon::Info
,
95
ButtonType
buttons =
ButtonType::OK
);
96
97
}
// namespace ultralight
Defines.h
AExport
#define AExport
Definition
Defines.h:41
String.h
ultralight::String
Unicode string container with conversions for UTF-8, UTF-16, and UTF-32.
Definition
String.h:31
ultralight
Root namespace for every public Ultralight type, function, and enumeration.
ultralight::DialogIcon
DialogIcon
Enum representing the icon to be displayed in a dialog.
Definition
Dialogs.h:54
ultralight::DialogIcon::Warning
@ Warning
Warning icon.
Definition
Dialogs.h:56
ultralight::DialogIcon::Info
@ Info
Information icon.
Definition
Dialogs.h:55
ultralight::DialogIcon::Error
@ Error
Error icon.
Definition
Dialogs.h:57
ultralight::DialogIcon::Question
@ Question
Question icon.
Definition
Dialogs.h:58
ultralight::ButtonResult
ButtonResult
Enum representing the result of a dialog button press.
Definition
Dialogs.h:73
ultralight::ButtonResult::Yes
@ Yes
"Yes" button was pressed
Definition
Dialogs.h:76
ultralight::ButtonResult::No
@ No
"No" button was pressed
Definition
Dialogs.h:77
ultralight::ButtonResult::Cancel
@ Cancel
"Cancel" button was pressed
Definition
Dialogs.h:75
ultralight::ShowMessageBox
ButtonResult ShowMessageBox(const String &title, const String &message, DialogIcon icon=DialogIcon::Info, ButtonType buttons=ButtonType::OK)
Show a modal message box with the specified title, message, icon, and buttons.
ultralight::ButtonType
ButtonType
Enum representing the button types in a dialog.
Definition
Dialogs.h:64
ultralight::ButtonType::OKCancel
@ OKCancel
"OK" and "Cancel" buttons
Definition
Dialogs.h:66
ultralight::ButtonType::YesNo
@ YesNo
"Yes" and "No" buttons
Definition
Dialogs.h:67
ultralight::ButtonType::OK
@ OK
Single "OK" button.
Definition
Dialogs.h:65
AppCore
Dialogs.h
Docs
C++ API
C API
Version
2.0
2.0
latest
1.4