Creating a one button modal alert

Hello, zaftige Leute!

I need to create a one button, modal alert with a progress bar - but I’m having some issues with this.

First, the documentation for AlertWindow::showMessageBoxAsync doesn’t correspond to the actual code. It tells me to pass a callback parameter if I want callbacks - but that parameter doesn’t exist - how you can do anything useful with a showMessageBoxAsync without a callback?

Second, I don’t see how to actually get my hands on the AlertWindow to add a progress bar if I use the convenience methods (which I’d love to).

I’m creating an AlertWindow directly, which is probably the simplest way around it - but I’m curious as to how showMessageBoxAsync could be used, and I’m pretty sure that the documentation needs a tweak or two…

So I don’t even seem to be able to use the plain AlertWindow. :frowning:

When I enter the modal state, I just can’t ever get input on that window - its button does not respond, neither does the keyboard accelerator.

Code is below:

  double progress = 0.0;
  bool cancelled = false;
  alert.addButton(CANCEL, 1, KeyPress(KeyPress::escapeKey));
  alert.enterModalState(true, new Callback(&cancelled));

  while (!cancelled) {
  DLOG(INFO) << "loop done";

[quote] while (!cancelled) {
This will block the message thread, this can’t work.

int ret = aw.runModalLoop();

And if you want to do something in a background thread and have a progress bar better use ThreadWithProgressWindow

I’d seen runModalLoop and ThreadWithProgressWindow, and they don’t quite fit the bill (though I can make 'em do what I want).

What’s happening is that there’s a thread that’s already running in the background. When the user requests a save, if that thread hasn’t finished calculation, I want to bring up a progress bar. That task can’t be a “ThreadWithProgressWindow” because nearly all the time there’s no progress window…

But of course you’re right that I’m blocking the message thread, so there needs to be a new thread somewhere - might as well be a ThreadWithProgressWindow.

I asked that second half of the question when I was pretty sleepy - still fairly sure that AlertWindow::showMessageBoxAsync is snafu’ed, at the very least because the documentation doesn’t match the actual code…!

Thanks, as always, for an excellent answer…