messagebox

messagebox.nim

Types

MessageBoxButtonData* = object
  flags*: uint32             ## ``MessageBoxButtonFlags``
  buttonid*: cint            ## User defined button id (value returned via ``showMessageBox()``)
  text*: cstring             ## The UTF-8 button text
  
Individual button data
MessageBoxColor* = object
  r*: uint8
  g*: uint8
  b*: uint8
RGB value used in a message box color scheme
MessageBoxColorType* {...}{.size: sizeof(cint).} = enum
  MESSAGEBOX_COLOR_BACKGROUND, MESSAGEBOX_COLOR_TEXT,
  MESSAGEBOX_COLOR_BUTTON_BORDER, MESSAGEBOX_COLOR_BUTTON_BACKGROUND,
  MESSAGEBOX_COLOR_BUTTON_SELECTED, MESSAGEBOX_COLOR_MAX
MessageBoxColorScheme* = object
  colors*: array[MESSAGEBOX_COLOR_MAX, MessageBoxColor]
A set of colors to use for message box dialogs
MessageBoxData* = object
  flags*: uint32             ## ``MessageBoxFlags``
  window*: Window            ## ``Parent window, can be `nil`
  title*: cstring            ## UTF-8 title
  message*: cstring          ## UTF-8 message text
  numbuttons*: cint
  buttons*: ptr MessageBoxButtonData
  colorScheme*: ptr MessageBoxColorScheme ## ``MessageBoxColorScheme``, can be `nil` to use system settings
  
MessageBox object containing title, text, window, etc.

Consts

MESSAGEBOX_ERROR* = 0x00000010
error dialog
MESSAGEBOX_WARNING* = 0x00000020
warning dialog
MESSAGEBOX_INFORMATION* = 0x00000040
informational dialog
MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT* = 0x00000080
buttons placed left to right
MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT* = 0x00000100
buttons placed right to left
MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT* = 0x00000001
Marks the default button when return is hit
MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT* = 0x00000002
Marks the default button when escape is hit

Procs

proc showMessageBox*(messageboxdata: ptr MessageBoxData; buttonid: ptr cint): cint {...}{.
    cdecl, importc: "SDL_ShowMessageBox", dynlib: SDL2_LIB.}

Create a modal message box.

messageboxdata The MessageBoxData object with title, text, etc.

buttonid The pointer to which user id of hit button should be copied.

Return -1 on error, otherwise 0 and buttonid contains user id of button hit or -1 if dialog was closed.

Note: This procedure 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.

proc showSimpleMessageBox*(flags: uint32; title: cstring; message: cstring;
                           window: Window): cint {...}{.cdecl,
    importc: "SDL_ShowSimpleMessageBox", dynlib: SDL2_LIB.}

Create a simple modal message box.

flags MessageBoxFlags

title UTF-8 title text

message UTF-8 message text

window The parent window, or nil for no parent

Return 0 on success, -1 on error

See also:

showMessageBox()