Skip to content

Commit

Permalink
Merge pull request #2338 from cwensley/curtis/mac-mouse-down-tracking…
Browse files Browse the repository at this point in the history
…-loop

Mac: Use NSRunLoopMode.Default for mouse tracking so UITimers work
  • Loading branch information
cwensley committed Oct 21, 2022
2 parents 2e6f094 + e4e7319 commit 49f15e6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Eto.Mac/Forms/MacView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ static partial class MacView
public static readonly object UseAlignmentFrame_Key = new object();
public static readonly object SuppressMouseEvents_Key = new object();
public static readonly object UseMouseTrackingLoop_Key = new object();
public static readonly object MouseTrackingRunLoopMode_Key = new object();
public static readonly IntPtr selSetDataProviderForTypes_Handle = Selector.GetHandle("setDataProvider:forTypes:");
public static readonly IntPtr selInitWithPasteboardWriter_Handle = Selector.GetHandle("initWithPasteboardWriter:");
public static readonly IntPtr selClass_Handle = Selector.GetHandle("class");
Expand Down Expand Up @@ -1348,6 +1349,12 @@ public bool UseMouseTrackingLoop
set => Widget.Properties.Set<bool>(MacView.UseMouseTrackingLoop_Key, value, true);
}

public NSRunLoopMode MouseTrackingRunLoopMode
{
get => Widget.Properties.Get<NSRunLoopMode>(MacView.MouseTrackingRunLoopMode_Key, NSRunLoopMode.Default);
set => Widget.Properties.Set<NSRunLoopMode>(MacView.MouseTrackingRunLoopMode_Key, value, NSRunLoopMode.Default);
}

public void SetAlignmentFrameSize(CGSize size)
{
if (UseAlignmentFrame)
Expand Down Expand Up @@ -1475,7 +1482,7 @@ public virtual MouseEventArgs TriggerMouseDown(NSObject obj, IntPtr sel, NSEvent
// Console.WriteLine("Entered MouseTrackingLoop");
do
{
var evt = app.NextEvent(NSEventMask.AnyEvent, NSDate.DistantFuture, NSRunLoopMode.EventTracking, true);
var evt = app.NextEvent(NSEventMask.AnyEvent, NSDate.DistantFuture, MouseTrackingRunLoopMode, true);

var evtType = evt.Type;
switch (evt.Type)
Expand Down

0 comments on commit 49f15e6

Please sign in to comment.