I'm trying to show a progress bar (but the same thing happens when I tried with buttons, sliders, any component) after clicking a MenuBar menu item:
(simplified code)
void MenuBar::menuItemSelected(int menuItemID, int topLevelMenuIndex){
switch (menuItemID) {
case ID_Open: {
ProgressBar* pr(new ProgressBar(mapping_editor->getPatchProgress()));
parent->addAndMakeVisible(pr);
pr->setBounds(300, 300, 200, 40);
mapping_editor->graph->loadPatch(instrument);
//the progress bar shows up only after this function is over, not before,
//so I cannot see it update
break;
}
}
}
}
Why are components only becoming visible when the function ends? The whole purpose of this is to add a progress bar before loading a patch to display the progress while the patch is loading. I tried all sorts of things to get this to work, including calling the loadPatch function from another thread, calling the parent and progress bar's repaint() method after adding it, adding the progress bar as a member before hand and only calling its setVisible() method in the menu callback, etc.