SDL 3.0
SDL_messagebox.h File Reference
+ Include dependency graph for SDL_messagebox.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SDL_MessageBoxButtonData
 
struct  SDL_MessageBoxColor
 
struct  SDL_MessageBoxColorScheme
 
struct  SDL_MessageBoxData
 

Macros

#define SDL_MESSAGEBOX_ERROR   0x00000010u
 
#define SDL_MESSAGEBOX_WARNING   0x00000020u
 
#define SDL_MESSAGEBOX_INFORMATION   0x00000040u
 
#define SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT   0x00000080u
 
#define SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT   0x00000100u
 
#define SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT   0x00000001u
 
#define SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT   0x00000002u
 

Typedefs

typedef Uint32 SDL_MessageBoxFlags
 
typedef Uint32 SDL_MessageBoxButtonFlags
 

Enumerations

enum  SDL_MessageBoxColorType {
  SDL_MESSAGEBOX_COLOR_BACKGROUND ,
  SDL_MESSAGEBOX_COLOR_TEXT ,
  SDL_MESSAGEBOX_COLOR_BUTTON_BORDER ,
  SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND ,
  SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED ,
  SDL_MESSAGEBOX_COLOR_MAX
}
 

Functions

int SDL_ShowMessageBox (const SDL_MessageBoxData *messageboxdata, int *buttonid)
 
int SDL_ShowSimpleMessageBox (SDL_MessageBoxFlags flags, const char *title, const char *message, SDL_Window *window)
 

Macro Definition Documentation

◆ SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT

#define SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT   0x00000002u

Marks the default button when escape is hit

Definition at line 64 of file SDL_messagebox.h.

◆ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT

#define SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT   0x00000001u

Marks the default button when return is hit

Definition at line 63 of file SDL_messagebox.h.

◆ SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT

#define SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT   0x00000080u

buttons placed left to right

Definition at line 53 of file SDL_messagebox.h.

◆ SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT

#define SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT   0x00000100u

buttons placed right to left

Definition at line 54 of file SDL_messagebox.h.

◆ SDL_MESSAGEBOX_ERROR

#define SDL_MESSAGEBOX_ERROR   0x00000010u

error dialog

Definition at line 50 of file SDL_messagebox.h.

◆ SDL_MESSAGEBOX_INFORMATION

#define SDL_MESSAGEBOX_INFORMATION   0x00000040u

informational dialog

Definition at line 52 of file SDL_messagebox.h.

◆ SDL_MESSAGEBOX_WARNING

#define SDL_MESSAGEBOX_WARNING   0x00000020u

warning dialog

Definition at line 51 of file SDL_messagebox.h.

Typedef Documentation

◆ SDL_MessageBoxButtonFlags

SDL_MessageBoxButtonData flags.

Since
This datatype is available since SDL 3.0.0.

Definition at line 61 of file SDL_messagebox.h.

◆ SDL_MessageBoxFlags

CategoryMessagebox

Message box support routines. SDL_MessageBox flags.

If supported will display warning icon, etc.

Since
This datatype is available since SDL 3.0.0.

Definition at line 48 of file SDL_messagebox.h.

Enumeration Type Documentation

◆ SDL_MessageBoxColorType

An enumeration of indices inside the colors array of SDL_MessageBoxColorScheme.

Enumerator
SDL_MESSAGEBOX_COLOR_BACKGROUND 
SDL_MESSAGEBOX_COLOR_TEXT 
SDL_MESSAGEBOX_COLOR_BUTTON_BORDER 
SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND 
SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED 
SDL_MESSAGEBOX_COLOR_MAX 

Size of the colors array of SDL_MessageBoxColorScheme.

Definition at line 92 of file SDL_messagebox.h.

93{
99 SDL_MESSAGEBOX_COLOR_MAX /**< Size of the colors array of SDL_MessageBoxColorScheme. */
SDL_MessageBoxColorType
@ SDL_MESSAGEBOX_COLOR_MAX
@ SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND
@ SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED
@ SDL_MESSAGEBOX_COLOR_BACKGROUND
@ SDL_MESSAGEBOX_COLOR_TEXT
@ SDL_MESSAGEBOX_COLOR_BUTTON_BORDER

Function Documentation

◆ SDL_ShowMessageBox()

int SDL_ShowMessageBox ( const SDL_MessageBoxData messageboxdata,
int *  buttonid 
)
extern

Create a modal message box.

If your needs aren't complex, it might be easier to use SDL_ShowSimpleMessageBox.

This function should be called on the thread that created the parent window, or on the main thread if the messagebox has no parent. It will block execution of that thread until the user clicks a button or closes the messagebox.

This function may be called at any time, even before SDL_Init(). This makes it useful for reporting errors like a failure to create a renderer or OpenGL context.

On X11, SDL rolls its own dialog box with X11 primitives instead of a formal toolkit like GTK+ or Qt.

Note that if SDL_Init() would fail because there isn't any available video target, this function is likely to fail for the same reasons. If this is a concern, check the return value from this function and fall back to writing to stderr if you can.

Parameters
messageboxdatathe SDL_MessageBoxData structure with title, text and other options.
buttonidthe pointer to which user id of hit button should be copied.
Returns
0 on success or a negative error code on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.
See also
SDL_ShowSimpleMessageBox

◆ SDL_ShowSimpleMessageBox()

int SDL_ShowSimpleMessageBox ( SDL_MessageBoxFlags  flags,
const char *  title,
const char *  message,
SDL_Window window 
)
extern

Display a simple modal message box.

If your needs aren't complex, this function is preferred over SDL_ShowMessageBox.

flags may be any of the following:

  • SDL_MESSAGEBOX_ERROR: error dialog
  • SDL_MESSAGEBOX_WARNING: warning dialog
  • SDL_MESSAGEBOX_INFORMATION: informational dialog

This function should be called on the thread that created the parent window, or on the main thread if the messagebox has no parent. It will block execution of that thread until the user clicks a button or closes the messagebox.

This function may be called at any time, even before SDL_Init(). This makes it useful for reporting errors like a failure to create a renderer or OpenGL context.

On X11, SDL rolls its own dialog box with X11 primitives instead of a formal toolkit like GTK+ or Qt.

Note that if SDL_Init() would fail because there isn't any available video target, this function is likely to fail for the same reasons. If this is a concern, check the return value from this function and fall back to writing to stderr if you can.

Parameters
flagsan SDL_MessageBoxFlags value.
titleuTF-8 title text.
messageuTF-8 message text.
windowthe parent window, or NULL for no parent.
Returns
0 on success or a negative error code on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 3.0.0.
See also
SDL_ShowMessageBox