Using MDI create two documents with names, a and b.
Click on each document and at activeDocumentChanged, getTheActive document and look at its name, it is the other documents name. At sometime later in the message loop it corrects itself.
The solution is to comment out the following in
void MultiDocumentPanel::updateOrder()
{
…
// if (components != oldList)
activeDocumentChanged();
}
Also MultiDocumentPanel::updateOrder should not rearrange the order of documents based on screen location. The order should remain the same as they are created. This is traditional Multiple Document Interface. You can test this with the DemoRunner.
and getActiveDocument should be
Component* MultiDocumentPanel::getActiveDocument() const noexcept
{
if (mode == FloatingWindows)
{
for (auto* child : getChildren())
if (auto* dw = dynamic_cast<MultiDocumentPanelWindow*> (child))
if (dw->isActiveWindow())
return dw->getContentComponent();
}
else if (tabComponent != nullptr)
{
return tabComponent->getTabContentComponent(tabComponent->getCurrentTabIndex());
}
return components.getLast();
}