NAME

SDL2::messagebox - Modal Message Box Support

SYNOPSIS

use SDL2 qw[:messagebox];

DESCRIPTION

SDL2::messagebox provides functions to display modal message boxes.

Functions

These functions may be imported by name or with the :messagebox tag.

SDL_ShowMessageBox( ... )

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.

Expected parameters include:

messageboxdata - the SDL2::MessageBoxData structure with title, text and other options
buttonid - the 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.

SDL_ShowSimpleMessageBox( ... )

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.

Expected parameters include:

flags - an SDL_MessageBoxFlags value
title - UTF-8 title text
message - UTF-8 message text
window - the parent window, or undef for no parent

Returns 0 on success or a negative error code on failure; call SDL_GetError( ) for more information.

Defined Variables and Enumerations

Variables may be imported by name or with the :messagebox tag. Enumerations may be imported with their given tag.

SDL_MessageBoxFlags

SDL2::MessageBox flags. If supported will display warning icon, etc.

SDL_MESSAGEBOX_ERROR - error dialog
SDL_MESSAGEBOX_WARNING - warning dialog
SDL_MESSAGEBOX_INFORMATION - informational dialog
SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT - buttons placed left to right
SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT - buttons placed right to left

SDL_MessageBoxButtonFlags

Flags for SDL2::MessageBoxButtonData.

SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT - Marks the default button when return is hit
SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT - Marks the default button when escape is hit

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

LICENSE

Copyright (C) Sanko Robinson.

This library is free software; you can redistribute it and/or modify it under the terms found in the Artistic License 2. Other copyrights, terms, and conditions may apply to data transmitted through this module.

AUTHOR

Sanko Robinson <sanko@cpan.org>