No it doesnot work, there is no effect at all after the button is clicked. I have following code.
void closeButtonPressed() override
{
// This is called when the user tries to close this window. Here, we'll just
// ask the app to quit when this happens, but you can change this to do
// whatever you need.
auto result = juce::NativeMessageBox::showYesNoBox(
juce::MessageBoxIconType::WarningIcon,
"Quit",
"Are you sure you want to Exit?",
nullptr,
nullptr
);
if (result)
JUCEApplication::getInstance()->systemRequestedQuit();
}
Ah, I see. I just tried it out. It won’t work this way unless you add JUCE_MODAL_LOOPS_PERMITTED=1 to your preprocessor definitions. Check out this thread for explanation! showModalDialog error
If I were you I’d probably go the async way. Could be like this:
void closeButtonPressed() override
{
// This is called when the user tries to close this window. Here, we'll just
// ask the app to quit when this happens, but you can change this to do
// whatever you need.
juce::NativeMessageBox::showAsync (juce::MessageBoxOptions()
.withIconType (juce::MessageBoxIconType::WarningIcon)
.withTitle ("Quit")
.withMessage ("Are you sure you want to exit?")
.withButton ("Yes")
.withButton ("No"),
[this] (int result) { if (result == 0) JUCEApplication::getInstance()->systemRequestedQuit(); });
}