docs
Loading...
Searching...
No Matches
Dialogs.h

Overview

Native modal message boxes for alerts and confirmations.

#include <AppCore/Dialogs.h>

This header provides ShowMessageBox() to display modal dialogs from the host OS. The call blocks until the user responds and returns the selected button result.

You can prompt the user for confirmation before discarding unsaved edits:

bool ConfirmDiscard() {
ButtonResult result = ShowMessageBox("Discard changes?",
"Your unsaved edits will be lost.",
DialogIcon::Question, ButtonType::YesNo);
return result == ButtonResult::Yes;
}

Main Thread and Linux Fallback

You must call ShowMessageBox() on the main thread.

On Linux, the library logs the message and returns the declining button (or ButtonResult::OK when it's the only button) whenever it can't display a dialog:

  • The call runs on a background thread.
  • The host system doesn't have GTK 3 installed.

In-Window HTML Dialogs

To style dialogs with HTML and CSS instead of native OS chrome, create a floating panel through Foreground. Setting FocusPolicy::Grab on the panel ensures it takes keyboard focus whenever it's shown.

See also
ShowMessageBox(), Foreground, FocusPolicy

Functions

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.

Namespaces

namespace  ultralight
 Root namespace for every public Ultralight type, function, and enumeration.

Enumerations

enum class  DialogIcon { Info , Warning , Error , Question }
 Enum representing the icon to be displayed in a dialog. More...
enum class  ButtonType { OK , OKCancel , YesNo }
 Enum representing the button types in a dialog. More...
enum class  ButtonResult { OK , Cancel , Yes , No }
 Enum representing the result of a dialog button press. More...

Go to the source code of this file.