Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac: Fix firing MouseEnter/Leave when scrolling #2532

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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