Very confused, why is there no "isPointInsideRect" function?

Where is the "isMouseInsideRect or “isMouseInsideComponent” or “doesRectOverlapRect”?

Trying not to post simple questions on the forum, but when I look at:

And I don’t see an obvious function that would be useful… I’m trying to learn how to use JUCE, but this is so discouraging.

Do I need to code everything myself? That’s fine if I do, but I don’t want to reinvent the wheel if I don’t have to. So teach me how to find answers. This is about learning to learn.

The Rectangle class would be more useful to look into for that stuff. That has contains() method with overloads that take a Point or another Rectangle etc.

Contains… there it is. Xenakios, fancy meeting you here.

Component also has isMouseOver.

if mouse is over a child component, is mouse also over the parent component?

bool 	isMouseOver (bool includeChildren=false) const

wtffffffffffff how would I have found that on my own? :confounded:

oh it’s in the function parameter

You just have to read through all the Component documentation, it’s long as hell but worth it…

ok soooo, is this the correct way to do this? IT’S WARKEENG!

virtual void mouseEnter(const MouseEvent& event) override
	if (Component::isMouseOver(true))

virtual void mouseExit(const MouseEvent& event) override
	if (!Component::isMouseOver(true))

edit: wait, i think the mouse drag out has an issue. I need to check if mouse is outside of component on mouse up maybe.

Hmm, don’t mouseEnter and mouseExit get called only when the mouse is inside the component anyway? So why do the explicit mouse over check?

ok, also, mouseUp event looks like it’s not triggered if mouse is not inside component, so I think I’ll have to implement this mouse handling in the parent.

without the checks, this happens:

ok it looks like I don’t need the check for mouseEnter, but I do need it for mouseExit.

Ah, of course. I haven’t looked much into overlapping components. Stuff is hard enough without considering those kinds of things! :smiley:

hmm, can’t figure out the mouse drag issue. mouseUp is not triggered for parent component if mouseDown was inside a child component. How should I deal with this?

To implement this, I’d follow a different approach:

Implement a MouseListener that, in its mouseMove() method, updates the visibility of those Components depending on whether the mouse is inside any of them.

Then add said MouseListener as a global listener with addGlobalMouseListener() in Desktop

No need to keep track of entered and exited states.

TBH when you start connecting components together by intercepting mouse events, you should treat that as a warning that you probably need to abstract the problem.

e.g. perhaps that child component should be responding to its own mouseUp by calling some kind of meaningful method on its parent to tell it what has happened?

ok, I already solved my problems actually ( mouseUp is not triggered for parent component if mouseDown was inside a child component ), but thanks for the tips! I’ll undoubtedly run into this kind of thing again.