Bool isLabelWithinComboBox

Would it be possible to have a bool method for Label that returns true if the label is within a ComboBox?

Thank you.

Why would you need that…? You could just use e.g. Component::findParentComponentOfClass to see if it’s inside a ComboBox, right?

Indeed, I’ve got

if (dynamic_cast <ComboBox*> (label.getParentComponent()) == nullptr)

working, it just seemed a little long, and requiring a cast. I guess when you think a method is obvious you just expect it to be there!

If I were you I’d use findParentComponentOfClass instead - you’re making an assumption there that the Label is a direct child of the ComboBox, which may not always be the case.

Even better, thank you!