[FR] AlertWindow::showNativeYesNoDialogBox


#1

Request to either add a static

bool AlertWindow::showNativeYesNoDialogBox (const String& title,
                                            const String& bodyText)
{
    return NativeMessageBox::showYesNoBox (AlertWindow::NoIcon, title, bodyText);
}

and

 bool JUCE_CALLTYPE NativeMessageBox::showYesNoBox (AlertWindow::AlertIconType iconType,
                                                      const String& title, const String& message,
                                                      Component* /*associatedComponent*/,
                                                      ModalComponentManager::Callback* callback)
{
    return OSXMessageBox::show (iconType, title, message, callback,
                                "Yes", "No", nullptr, callback != nullptr) == 1;
}

… or have a version where we can pass the button text values??

Thanks,

Rail


#2

What’s wrong with AlertWindow::showYesNoCancelBox? I guess you don’t want the cancel button?


#3

a) I want a Native window

b) I don’t want a Cancel button

Rail


#4

… and for extra points… let us change the default button :slight_smile:

Cheers,

Rail


#5

How about changing

static bool JUCE_CALLTYPE showNativeDialogBox (const String& title,
                                               const String& bodyText,
                                               bool isOkCancel)

to

static bool JUCE_CALLTYPE showNativeDialogBox (const String& title,
                                               const String& bodyText,
                                               bool isOkCancel,
                                               const String& okButtonText = String(),
                                               const String& cancelButtonText = String());

Would that work for you?


#6

You must have been mind melding with me earlier today… I was thinking of that exact same option.

EDIT: Well close… I was thinking:

static bool JUCE_CALLTYPE showNativeDialogBox (const String& title,
                                               const String& bodyText,
                                               bool isOkCancel,
                                               const String& okButtonText = "OK",
                                               const String& cancelButtonText = "Cancel");

Cheers,

Rail


#7

Yes, I was actually thinking the same. After implementing this for all platforms and working on windows last, I figured out why JUCE does not support this:

So you’ll likely need to implement your own dialog GUI anyway for Windows. Do you still want me to do this?


#8

I can just use a MB_YESNO MessageBox in Windows… There’s a lot of code differences between the platforms for this installer… mainly due to the Security Services… selecting a different AlertBox will be the easiest thing I’ll have to deal with :slight_smile:

Of course going back to my original post… you could go to a separate method instead of changing the button text

int JUCE_CALLTYPE NativeMessageBox::showYesNoBox (AlertWindow::AlertIconType iconType,
                                                        const String& title, const String& message,
                                                        Component* associatedComponent,
                                                        ModalComponentManager::Callback* callback)
{
    ScopedPointer<WindowsMessageBox> mb (new WindowsMessageBox (iconType, title, message, associatedComponent,
                                                                MB_YESNO, callback, callback != nullptr));
    if (callback == nullptr)
        return mb->getResult();

    mb.release();
    return 0;
}

I’d like the change… but that’s up to y’all and Jules.

(If I recall correctly… there are some undocumented ways to change the buttons’ text which I’ve done in Windows File Chooser dialogs in the (way distant) past… but I highly doubt you’d want to go there).

Thanks,

Rail


#9

OK, I’ve finally pushed the showYesNoBox solution do develop.


#10

Thanks Fabian

Much appreciated!

The only note is a small typo in the header from a copy/paste

/** Shows a dialog box with three buttons.

Best,

Rail


#11

Thanks!