Native Ok/Cancel message boxes with custom button titles



I've added support for custom button titles in native Ok/Cancel message boxes, on platforms which support it. 

Before this fix, AlertWindow::showOkCancelBox() only used the button1Text and button2Text parameters for non-native message boxes.

Here's the commit:





Hi Dan,

The ability to add custom text to the buttons of a NativeMessageBox is certainly useful. A proper implementation would need to cover all the different cases (1, 2 and 3 buttons, not just the OkCancel case). It would also probably require new functions with a cleaner interface as well. I would like to avoid adding the buttonTexts as additional parameters to the existing functions, as in your commit, since some preceding arguments have default values and can be omitted.

Imho this would only be worth the effort if it would then also work cross-platform. However there seems to be no way to easily make it work on Windows. Unless you know a good way to add that, I would prefer to leave the feature out for now.


I've done this on Windows many years ago, by hooking the CreateWindow function (to get the HWND of the message box), then getting the buttons through querying for the HWND of ID_OK, ID_CANCEL and ID_YES and setting the button texts with Win32 SetWindowText.

This maybe doesn't qualify as "easy" :)

To make the buttons resize to fit the text (if too large) is an excercise left for the reader... ;)


Hi Timur,

JUCE's text boxes classes and methods already don't have full cross-platform support - for example additional buttons only work on OS X IIRC.

I think that's OK though - This is basic enough functionality that it's better to not let Perfect be the Enemy of the Good.

So I'm for adding the custom button titles too :)