# SDL message box

**URL:** <https://discourse.libsdl.org/t/sdl-message-box/21163>\
**Category:** SDL Development\
**Created:** [January 17, 2015, 2:10pm UTC](https://discourse.libsdl.org/t/sdl-message-box/21163 "2015-01-17T14:10:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel1985](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/d/a5b964/32.png) [@Daniel1985](https://discourse.libsdl.org/u/Daniel1985)\
**Post date:** [January 17, 2015, 2:10pm UTC](https://discourse.libsdl.org/t/sdl-message-box/21163/1 "2015-01-17T14:10:01Z")

</div>

Hi!

I’m trying to create a message box (SDL\_ShowMessageBox, not SDL\_ShowSimpleMessageBox) with buttons in it and I now have 2 issues / questions:

1. How does the color scheme for a specific button work? I know there is a colorScheme pointer inside the SDL\_MessageBoxData, which I’ve created, but even if I, for example, set the SDL\_MESSAGEBOX\_COLOR\_BACKGROUND to red, the message box background color is the default (gray). Am I missing something?

2. How can I prevent the user from access the SDL window when the message box is open? When I have a message box open and the user clicks on the SDL window (which is behind the message box), I want the focus to return / remain on the message box. Can this be done?

---

<div class="post-metadata">

**Author:** ![Daniel\_Gibson](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/daniel_gibson/32/3010_2.png) [@Daniel\_Gibson](https://discourse.libsdl.org/u/Daniel_Gibson)\
**Post date:** [January 17, 2015, 3:14pm UTC](https://discourse.libsdl.org/t/sdl-message-box/21163/3 "2015-01-17T15:14:48Z")

</div>

Why did you sent this message (with only minor changes) three times?On 01/17/2015 03:11 PM, Naith wrote:

> Hi!
> 
> I’m trying to create a message box (SDL\_ShowMessageBox, not  
> SDL\_ShowSimpleMessageBox) with buttons in it and I now have 2 issues /  
> questions:
> 
> 1. How does the color scheme for the message box work? I know there is a  
> colorScheme pointer inside the SDL\_MessageBoxData, which I’ve created,  
> but even if I, for example, set the SDL\_MESSAGEBOX\_COLOR\_BACKGROUND to  
> red, the message box background color is the default (gray). Am I  
> missing something?
> 
> 2. How can I prevent the user from access the SDL window when the  
> message box is open? When I have a message box open and the user clicks  
> on the SDL window (which is behind the message box), I want the focus to  
> return / remain on the message box. Can this be done?

---

<div class="post-metadata">

**Author:** ![Jonas\_Kulla](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@Jonas\_Kulla](https://discourse.libsdl.org/u/Jonas_Kulla)\
**Post date:** [January 17, 2015, 3:02pm UTC](https://discourse.libsdl.org/t/sdl-message-box/21163/4 "2015-01-17T15:02:17Z")

</div>

2015-01-17 15:10 GMT+01:00 Naith :

> Hi!
> 
> I’m trying to create a message box (SDL\_ShowMessageBox, not  
> SDL\_ShowSimpleMessageBox) with buttons in it and I now have 2 issues /  
> questions:
> 
> 1. How does the color scheme for a specific button work? I know there is a  
> colorScheme pointer inside the SDL\_MessageBoxData, which I’ve created, but  
> even if I, for example, set the SDL\_MESSAGEBOX\_COLOR\_BACKGROUND to red, the  
> message box background color is the default (gray). Am I missing something?
> 
> 2. How can I prevent the user from access the SDL window when the message  
> box is open? When I have a message box open and the user clicks on the SDL  
> window (which is behind the message box), I want the focus to return /  
> remain on the message box. Can this be done?

For 2), the SDL\_MessageBoxData struct has a “window” member to specify the  
parent SDL\_Window, this  
should be enough for the platform code to make the message box transient  
for your main window so it  
stays on top.

---

<div class="post-metadata">

**Author:** ![Daniel\_Gibson](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/daniel_gibson/32/3010_2.png) [@Daniel\_Gibson](https://discourse.libsdl.org/u/Daniel_Gibson)\
**Post date:** [January 17, 2015, 8:51pm UTC](https://discourse.libsdl.org/t/sdl-message-box/21163/6 "2015-01-17T20:51:31Z")

</div>

> Daniel Gibson wrote:  
> Why did you sent this message (with only minor changes) three times?
> 
> Because I wasn’t pleased with the text and the edit-function is (for  
> some reason) disabled…

The edit function is disabled because the forum is synchronized with a  
mailing list (where editing or deleting posts is impossible).

Please don’t do that.  
If you want to add something to your post, just answer to your original  
post, don’t duplicate it.

Thanks!

Cheers,  
DanielAm 17.01.2015 19:35, schrieb Naith:

> On 01/17/2015 03:11 PM, Naith wrote:

---

<div class="post-metadata">

**Author:** ![Jonas\_Kulla](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@Jonas\_Kulla](https://discourse.libsdl.org/u/Jonas_Kulla)\
**Post date:** [January 17, 2015, 7:11pm UTC](https://discourse.libsdl.org/t/sdl-message-box/21163/9 "2015-01-17T19:11:58Z")

</div>

2015-01-17 19:37 GMT+01:00 Naith :

> And of course I forgot to mention this:
> 
> Jonas, my SDL window is specified in my SDL\_MessageBoxData struct but the  
> window still won’t stay “in the background” when it is clicked. What can be  
> the reason for that?

What operating system are you on? On Linux/X11, the parent window properly  
stays  
behind the message box on my system (although it can gain keyboard focus).
