Modal state causing unrelated mouseExit() in mouse listeners


  1. Attach a MouseListener to a Component in the hierarchy of a TopLevelWindow
  2. Put the application into the modal state, calling enterModalState() on a new unrelated TopLevelWindow.


The MouseListener will receive mouseExit messages without corresponding mouseEnter messages when the mouse goes in and out of the associated Component.


Either the mouseExit should never be sent (preferred if mouse clicks are disabled in the modal state), or both mouseEnter and mouseExit should be sent (preferred if mouse clicks pass through unrelated TopLevelWindow in the modal state).

Ok, how about this…

void Component::internalMouseExit (MouseInputSource& source, const Point<int>& relativePos, const Time& time) { if (isCurrentlyBlockedByAnotherModalComponent() && source.getComponentUnderMouse() != this) return;

That works!