When we show a PopupMenu after a mouseEnter event, the mouseExit event is ignored. I found the exact issue discussed here :
I also noticed this issue with all component that display onDesktop, or enterModalState like FileChooser. Currently, I just manually call the mouseExit before the PopupMenu, but seems nasty to me.
Mouseexit before the popup is also ātoo earlyā. What we did was add an endhover method to our interfaces and call it from the popup menu async call on exit (being careful that the object lifetime outlasted the menu)
I think the current behaviour is probably incorrect - itās surprising that mouseEnter/mouseExit calls become unbalanced when displaying a modal component, so JUCE should probably attempt to keep these calls balanced.
The question then is where the extra mouseExit calls should happen. The most promising options are immediately before entering modal state, and immediately after exiting modal state.
Of the two options, I think the first option feels more consistent with the rest of JUCEās mouse handling. Normally, a mouse source is only considered to be over a single component, so having a āstackā of mouseEnter events that are later matched by mouseExit calls (implying that the mouse source is logically over multiple components simultaneously) would be surprising to users. JUCE already has logic in place to send mouseEnter events to hovered components when a modal state ends, so it would make sense to send mouseExit events to hovered components just before a modal state starts too.
The downside of this approach is that it wonāt work āout of the boxā for @baconpaulās use-case. As I understand it, the goal there was to paint a button in a special state if it is hovered, or if a popup menu is open. Iād consider āhover stateā and āmodal active stateā to be different concepts, so I think itās reasonable to require the state of the menu to be tracked separately, and to manually repaint the button when the menu is closed.
Iāll try adding extra mouseExit calls immediately before entering a modal state and make sure everything works in the way that I expect. In the meantime Iād welcome any thoughts/feedback you may have.
We actually argued about it a little and realized while it didnāt matter much end hover on menu close was epsilon more pleasing. If mouse exit had been called when the menu was opened we would have never even thought about it tbh so donāt guide your decision on my use case
I think calling mouse exit when you launch the popup is smart and the right semantic.