In TooltipWindow getTipFor being virtual would let me use component id’s to load tooltips from a file, something like this:
class JTooltipWindowUsingXml : public TooltipWindow
{
public:
JTooltipWindowUsingXml(const File & tooltipFile)
{
ScopedPointer<XmlElement> x = XmlDocument(tooltipFile).getDocumentElement();
jassert(x);
if (!x)
return;
forEachXmlChildElement(*x, e)
{
auto id = e->getChildElementAllSubText("component", {});
auto tip = e->getChildElementAllSubText("tooltip", {});
jassert(id.isNotEmpty() && tip.isNotEmpty());
tooltips[id] = tip;
}
}
String getTipFor (Component* comp) override
{
if (comp == nullptr)
return;
auto id = comp->getComponentID();
auto it = tooltips.find(id);
if (it == tooltips.end())
return TooltipWindow::getTipFor(comp);
return it->second;
}
private:
std::unordered_map<String, String> tooltips;
};
And then I can delegate all the debate about tooltips to the product management team!
![]()

