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 fdf0b8b
Showing 1 changed file with 32 additions and 0 deletions.
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 fdf0b8b

Please sign in to comment.