Hello everyone,
I’m trying to use the SDL_ShowMessageBox function but it does not behave as described in the documentation.
I’m using SDL2 and programming on W10pro.
Hereafter is a simple code allowing to highlight my concern.
int main(int argc, char argv[])
{
SDL_Window myWindow = NULL;
SDL_Init(SDL_INIT_VIDEO);
myWindow = SDL_CreateWindow(“Message box test”, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 600, 400, SDL_WINDOW_RESIZABLE);
const SDL_MessageBoxButtonData buttons[] = {
{ 0, 0, “button 0” },
{ 0, 1, “button 1” },
{ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 2, “button 2” },
{ SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 3, “button 3” },
};
const SDL_MessageBoxColorScheme colorScheme = {
{
{ 255, 0, 0 },
{ 0, 255, 0 },
{ 255, 255, 0 },
{ 0, 0, 255 },
{ 255, 0, 255 }
}
};
const SDL_MessageBoxData messageboxdata = {
SDL_MESSAGEBOX_WARNING,
myWindow,
“Attention”,
“Hello”,
SDL_arraysize(buttons),
buttons,
&colorScheme
};
int buttonid;
SDL_ShowMessageBox(&messageboxdata, &buttonid);
SDL_Log(“buttonid: %d”,buttonid);
SDL_DestroyWindow(myWindow);
SDL_Quit();
return EXIT_SUCCESS;}
The first problem I see is that the color scheme does not seem to be applied. The message box remains with the system default color.
The second problem is that it looks like the function does not care about the MessageBoxButtonData flags like the SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT flag for example. It looks like the button defined at the second element of the SDL_MessageBoxButtonData structure is always considered as the return default button.
Here after is a screen capture of what is displayed on my system. It clearly show that the user defined color scheme is not applied and the the default button is button 1 which is also confirmed by SDL_Log when I hit the return key.
Is there something wrong in my code preventing the function to behave as documented?
Thanks.