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.
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.
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?