Thank you for the suggestions.
If there is any other window, e.g. a popup, tooltip or a window from a different application, which partly covers the panel, then entering the panel and leaving it into the overlapping window will let the panel remain highlighted.
- hover-out-through-tooltip.gif (59.97 KiB) Viewed 3800 times
In my first attempt to solve this issue before writing the post, I tried working with mouse positions and checking boundaries and came up with a similar solution, but at some point I must have done something differently as the panel occasionally remained highlighted when I moved the mouse quickly onto a child and out of the panel. And it was not a border issue as in your example, because my elements have been centered with a lot of space between panel and children.
Then I came up with the following attempt, that covered the flaws of the first one:
I used a common integer variable. The panel and all of its children get the OnEnter and OnLeave events and they all increase the integer on enter and decrease it on leave. Every OnEnter starts a common timer, that checks the integer every 50ms and if it is 0, the timer restores the original background color and stops itself. It works quite well and I didn't measure any extraordinary resource consumption, but still it feels wrong to do it just for a visual effect. And after all it has even worse issues with overlapping windows.
So, I guess the final solution might be to have a timer to make a conjunction between the leave event on the panel and the enter event on the child and to not just check the panel boundaries, but to check if there was an enter event on a child or if there was no enter event at all, because the mouse just left the panel by entering another window.
Actually, I was hoping that I'm just missing a flag or similar, which disables the leave event on the parent when you leave into a child, but fires the leave event when the parent is left, even when leaving quickly from children to outisde.