# Display Alertwindow Async

**URL:** <https://forum.juce.com/t/display-alertwindow-async/17769>\
**Category:** General JUCE discussion\
**Created:** [May 19, 2016, 4:38pm UTC](https://forum.juce.com/t/display-alertwindow-async/17769 "2016-05-19T16:38:53Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![AaronLeese](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/aaronleese/32/624_2.png) [@AaronLeese](https://forum.juce.com/u/AaronLeese)\
**Post date:** [May 19, 2016, 4:38pm UTC](https://forum.juce.com/t/display-alertwindow-async/17769/1 "2016-05-19T16:38:53Z")

</div>

Since we don’t use modal loops in plugins, I make use of the showMessageBoxAsync method to show alerts asynchronously.

I would like to do the same with OkCancel boxes, or other custom Alertwindows, but can’t seem to see an easy way to do this. Maybe I’m missing something simple?

Any chance you could make the AlertWindowInfo class accessible, or add a few methods for constructing/displaying arbitrary AlertWindows in an asyncronous manner?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 20, 2016, 6:51am UTC](https://forum.juce.com/t/display-alertwindow-async/17769/2 "2016-05-20T06:51:48Z")

</div>

Yes - definitely a little task that we should do soon. What I’ve been meaning to do is to add some lambda-based methods so you can kick off an async dialog and have it call ok/cancel lambdas when it’s done.

---

<div class="post-metadata">

**Author:** ![AaronLeese](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/aaronleese/32/624_2.png) [@AaronLeese](https://forum.juce.com/u/AaronLeese)\
**Post date:** [May 20, 2016, 4:58pm UTC](https://forum.juce.com/t/display-alertwindow-async/17769/3 "2016-05-20T16:58:12Z")

</div>

Excellent! Can’t wait to see it.

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [September 11, 2017, 4:44pm UTC](https://forum.juce.com/t/display-alertwindow-async/17769/4 "2017-09-11T16:44:43Z")

</div>

Any news on this lambda dialog box ?  
That would be a great addition for simple and clean async dialog window that avoids spaghetti code

Thanks !

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [September 11, 2017, 4:58pm UTC](https://forum.juce.com/t/display-alertwindow-async/17769/5 "2017-09-11T16:58:48Z")

</div>

As a side note, it seems that there is no way to use AlertWindow facilities like addCustomComponent or addTextEditor and easily have it work async with a nice lambda based callback;

That would allow to quickly setup a simple dialog box with ok/cancel and few options and defined inline with the rest of the code.

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [September 12, 2017, 11:26am UTC](https://forum.juce.com/t/display-alertwindow-async/17769/6 "2017-09-12T11:26:22Z")

</div>

OK I’ve added a new `NativeMessageBox::showMessageBox` method which accepts a lambda as a callback and has parameter to detemine the dialog type (ok, yesno, yesnocancel,…).

It’s on develop with commit [8483aa4](https://github.com/WeAreROLI/JUCE/commit/8483aa4aea3af3522baa5a6ba2c22931e3aa7a02).

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [September 12, 2017, 12:28pm UTC](https://forum.juce.com/t/display-alertwindow-async/17769/7 "2017-09-12T12:28:24Z")

</div>

Thanks a lot.  
Lambda definitely helps a lot when moving from modal to async dialog thanks to the capture system.

Maybe this should be done using a concrete std::function based ModalComponentManager::Callback implementation instead ?  
So it works with all the widget using ModalComponentManager::Callback including PopupMenu ? (and add hints toward this in the doc)

new ModalComponentManager::FunctionCallback([] { myyCode Here}) should work, right ?

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [September 13, 2017, 9:46am UTC](https://forum.juce.com/t/display-alertwindow-async/17769/8 "2017-09-13T09:46:45Z")

</div>

Looks it already there in fact  
ModalCallbackFunction

So maybe you should maybe discard the whole commit and update the doc to add more hints towards this.  
as it looks like that even you didn’t knew it was already possible 🙂

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [September 13, 2017, 10:14am UTC](https://forum.juce.com/t/display-alertwindow-async/17769/9 "2017-09-13T10:14:56Z")

</div>

hmmmm embarrassing 😊. A revert for that commit and better documentation will appear on the develop branch shortly.

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [September 13, 2017, 10:44am UTC](https://forum.juce.com/t/display-alertwindow-async/17769/10 "2017-09-13T10:44:56Z")

</div>

Thanks !  
Much appreciated.
