showOkCancelBox callback result value is always 1

Hi all!
I have the following lines of code to show an alert window with Ok/Cancel options in my JUCE app.

const auto callback = juce::ModalCallbackFunction::create([this](int result) {
    if (result) {
        // Do something
    }// result == 1 means you click OK
    else {
        // Do something else
    }// result == 0 means you click Cancel
});

juce::AlertWindow::showOkCancelBox(juce::MessageBoxIconType::WarningIcon, "MyTitle", "MyMessage", "Ok", "Cancel", nullptr, callback);

It was working fine on JUCE 7.0.1 (I would get result == 1 when pressing Ok and result == 0 when pressing Cancel) but we had to upgrade our working JUCE version to 7.0.10.
Now (on Windows) no matter what button I press on the window, the callback gets called with a result value of 1. I’ve checked and I’m getting the same behavior on 7.0.7, 7.0.9 and 7.0.12. This appears to be working fine on MacOS.

Any idea of what could be causing this?

Thanks!

Hi!

I tried to repro this but wasn’t able to get the same result. I used your code verbatim and it worked correctly on 7.0.9 all the way up to develop.

I would explicitly check the value of result instead of doing a bool comparison to see if something else is going on.

Hey, thanks for taking the time to check it!
Are you on MacOS?
I think I was only getting this on Windows.

I tested on Windows.