Skip to content

Commit

Permalink
Mac: Fix firing MouseEnter/Leave when scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
cwensley committed Jul 24, 2023
1 parent ca2cd5d commit b0ba7e4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/monomac
32 changes: 32 additions & 0 deletions src/Eto.Mac/Forms/MacView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,28 @@ public void FireMouseLeaveIfNeeded(bool async)
h.Callback.OnMouseLeave(h.Widget, MacConversions.GetMouseEvent(h, theEvent, false));
}
}
public void FireMouseEnterIfNeeded(bool async)
{
var h = Handler;
if (h == null || entered) return;
entered = true;
if (async)
{
Application.Instance.AsyncInvoke(() =>
{
if (h.Widget.IsDisposed)
return;
var theEvent = NSApplication.SharedApplication.CurrentEvent;
h.Callback.OnMouseEnter(h.Widget, MacConversions.GetMouseEvent(h, theEvent, false));
});
}
else
{
var theEvent = NSApplication.SharedApplication.CurrentEvent;
h.Callback.OnMouseEnter(h.Widget, MacConversions.GetMouseEvent(h, theEvent, false));
}
}

}

Expand Down Expand Up @@ -777,6 +799,16 @@ public virtual void UpdateTrackingAreas()

tracking = new NSTrackingArea(frame, options, mouseDelegate, null);
EventControl.AddTrackingArea(tracking);

// when scrolling we need to fire the events manually
if (Widget.Loaded)
{
var mousePosition = PointFromScreen(Mouse.Position);
if (frame.Contains(mousePosition.ToNS()))
mouseDelegate.FireMouseEnterIfNeeded(false);
else
mouseDelegate.FireMouseLeaveIfNeeded(false);
}
}
}

Expand Down

0 comments on commit b0ba7e4

Please sign in to comment.