I’m struggling with a seemingly trivial task for hours:
What is the best way for batch-like code run on the message thread to show a (temporary) notification window to provide updates on progress (labels, progress bar)?
I created a window with a label component, which seems to work, but it either it doesn’t show up on screen, or does so only randomly. Updating the label’s text has no effect.
Label* label = new Label(); label->setText("Please wait ...", dontSendNotification); label->setJustificationType(Justification::centred); label->setBounds(0,0, 400, 90); DocumentWindow win (JucePlugin_Name, GlobalWindowBackground, 0); win.setUsingNativeTitleBar (true); win.setContentOwned (label, true); win.setTitleBarHeight (0); win.setTitleBarButtonsRequired (DocumentWindow::closeButton, false); win.centreAroundComponent(nullptr, 400, 100); win.setVisible (true); win.toFront(false); win.setAlwaysOnTop(true); // doing task stuff here label->setText("Doing this now", dontSendNotification); // do even more stuff ... label->setText("Doing more stuff now", dontSendNotification); // window gets deleted and closed when method is exited
I understand that a display refresh can be forced with MessageManager::getInstance()-> runDispatchLoopUntil(100) after opening the window and updating the label. This however seems to be incompatible with MessageManager::getInstance()->callFunctionOnMessageThread() , which is used to run this batch and happens to hang after closing the window.
What’s the recommended way of pushing some task to the message thread and showing a progress notice? What am I missing?