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?
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.
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.
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,…).
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 ?
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