sdlShowMessageBox function

bool sdlShowMessageBox(
  1. Pointer<SdlMessageBoxData> messageboxdata,
  2. Pointer<Int32> buttonid
)

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.

\param messageboxdata the SDL_MessageBoxData structure with title, text and other options. \param buttonid the pointer to which user id of hit button should be copied. \returns true on success or false on failure; call SDL_GetError() for more information.

\since This function is available since SDL 3.1.3.

\sa SDL_ShowSimpleMessageBox

extern SDL_DECLSPEC bool SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)

Implementation

bool sdlShowMessageBox(
    Pointer<SdlMessageBoxData> messageboxdata, Pointer<Int32> buttonid) {
  final sdlShowMessageBoxLookupFunction = libSdl3.lookupFunction<
      Uint8 Function(
          Pointer<SdlMessageBoxData> messageboxdata, Pointer<Int32> buttonid),
      int Function(Pointer<SdlMessageBoxData> messageboxdata,
          Pointer<Int32> buttonid)>('SDL_ShowMessageBox');
  return sdlShowMessageBoxLookupFunction(messageboxdata, buttonid) == 1;
}