Detect Mouse Down Inside PopupMenu?

Hi! I have a component which gets automatically hidden when a mouse click happens outside of itself.

The code is like:

    if (isVisible()) {
        if (!getScreenBounds().contains(e.getScreenPosition())) {
            setVisible(false);
       }
    }

Now – I’ve added a Popup into that component, and I’d like It to not hide when the popup shows, even though it’s outside of the component, is there a way to tell if an original event component is a popup menu item? it seems those classes are private members so something like:

    if (isVisible()) {
        if (!getScreenBounds().contains(e.getScreenPosition())) {
            if (dynamic_cast<PopupMenu::HelperClasses::ItemComponent*>(e.originalComponent) == nullptr) {
                setVisible(false);
            }
        }
    }

Isn’t available. Is there a way to detect a mouse down to a popup from a desktop mouse listener?