# AlertWindow/NativeMessageBox::show() return value clarification

**URL:** <https://forum.juce.com/t/alertwindow-nativemessagebox-show-return-value-clarification/69152>\
**Category:** General JUCE discussion\
**Created:** [July 14, 2026, 11:57am UTC](https://forum.juce.com/t/alertwindow-nativemessagebox-show-return-value-clarification/69152 "2026-07-14T11:57:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chkn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/chkn/32/3862_2.png) [@chkn](https://forum.juce.com/u/chkn)\
**Post date:** [July 14, 2026, 11:57am UTC](https://forum.juce.com/t/alertwindow-nativemessagebox-show-return-value-clarification/69152/1 "2026-07-14T11:57:45Z")

</div>

in BREAKING\_CHANGES.md I read:

`The value returned by AlertWindow::show() has been changed so that it is consistent between native and non-native windows. The documentation has been updated to describe the new behaviour.`

**It’s these kinds of changes that make me wake up in the middle of the night drenched in sweat.**

For example, the setup routine uses NativeMessageBox to ask whether a failed write operation should be retried, canceled, or ignored. A change could have massive impact on my software.

Does “native-window” refer to NativeMessageBox? I’m confused.

When I read the documentation:

AltertWindow::show()

```auto
 - Three buttons:
            - button[0] returns 1
            - button[1] returns 2
            - button[2] returns 0

        Another way of expressing this is that, when there are N buttons, then the result code for
        button X is equal to ((X + 1) % N).

```

NativeMessageBox::show()

` @returns the index of the button that was clicked.`

PS: every behavior changed should always result in an API change

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [July 14, 2026, 12:27pm UTC](https://forum.juce.com/t/alertwindow-nativemessagebox-show-return-value-clarification/69152/2 "2026-07-14T12:27:40Z")

</div>

> [@chkn](#):
>
> It’s these kinds of changes that make me wake up in the middle of the night drenched in sweat.

Wow, I would have filed that API under comedy…

If you cannot return the button index, which would be the expected, how about letting the user attach an int or a juce::var in .withButton() ?

```auto
auto result = juce::AlertWindow::show (MessageBoxOptions()
    .withButton ("Ok", 1)
    .withButton ("Cancel", 2)
    .withButton ("Whatever", 3));

```

That way the user can use their own enum or magic numbers, if they prefer that.  
A default of -1 could restore the original behaviour and ether return the button index, or if there is a technical advantage, return your proposed formula.

---

<div class="post-metadata">

**Author:** ![chkn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/chkn/32/3862_2.png) [@chkn](https://forum.juce.com/u/chkn)\
**Post date:** [July 16, 2026, 12:39pm UTC](https://forum.juce.com/t/alertwindow-nativemessagebox-show-return-value-clarification/69152/3 "2026-07-16T12:39:18Z")

</div>

I think that would be a nice change! The old form could be marked as deprecated.

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [October 16, 2026, 11:50am UTC](https://forum.juce.com/t/alertwindow-nativemessagebox-show-return-value-clarification/69152/4 "2026-10-16T11:50:49Z")

</div>

We’ve updated the API for message box result codes:

> <https://github.com/juce-framework/JUCE/commit/637a7344349f03dcbd365f725b8553dafb661d66>

This is a breaking change, but definitely warranted in this case.

Thanks for nudging us to fix this!
