Skip to content

Commit

Permalink
Merge pull request #2537 from cwensley/curtis/mac-mousedown-when-not-…
Browse files Browse the repository at this point in the history
…in-bounds

Mac: Fix firing MouseDown when not in bounds of the control
  • Loading branch information
cwensley committed Jul 31, 2023
2 parents 51eb856 + d7e194a commit 88fec23
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Eto.Mac/Forms/MacView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1538,16 +1538,21 @@ protected virtual bool OnAcceptsFirstMouse(NSEvent theEvent)

public virtual MouseEventArgs TriggerMouseDown(NSObject obj, IntPtr sel, NSEvent theEvent)
{
if (!Enabled)
return null;

var args = MacConversions.GetMouseEvent(this, theEvent, false);

// ensure we're actually in the control's bounds
if (!new RectangleF(Size).Contains(args.Location))
return null;

// Flag that we are going to use a mouse tracking loop
// if this is set to false during the OnMouseDown/OnMouseDoubleClick, then we won't
// do a mouse tracking loop. This is needed since the mouse up event gets buried when
// showing context menus, dialogs, etc.
MacView.InMouseTrackingLoop = true;

if (!Enabled)
return null;

var args = MacConversions.GetMouseEvent(this, theEvent, false);

if (theEvent.ClickCount >= 2)
Callback.OnMouseDoubleClick(Widget, args);

Expand Down

0 comments on commit 88fec23

Please sign in to comment.