mirror of
https://github.com/cyanfish/naps2.git
synced 2024-09-11 15:26:55 +03:00
Mac: Fix Eto invoker
This commit is contained in:
parent
14a0ce8934
commit
72ce74d7b0
@ -26,6 +26,20 @@ public class MacEtoPlatform : EtoPlatform
|
||||
return new Application(Platforms.macOS);
|
||||
}
|
||||
|
||||
public override void Invoke(Application application, Action action)
|
||||
{
|
||||
// TODO: Eto PR to use this instead of DispatchQueue.MainQueue
|
||||
// Invoking directly on DispatchQueue ignores the run loop mode, which can mean something like spawning a modal
|
||||
// form doesn't behave normally.
|
||||
// https://stackoverflow.com/questions/9335434/whats-the-difference-between-performselectoronmainthread-and-dispatch-async
|
||||
NSApplication.SharedApplication.InvokeOnMainThread(action);
|
||||
}
|
||||
|
||||
public override void AsyncInvoke(Application application, Action action)
|
||||
{
|
||||
NSApplication.SharedApplication.BeginInvokeOnMainThread(action);
|
||||
}
|
||||
|
||||
public override IListView<T> CreateListView<T>(ListViewBehavior<T> behavior) =>
|
||||
new MacListView<T>(behavior);
|
||||
|
||||
|
@ -13,18 +13,18 @@ public class EtoInvoker : IInvoker
|
||||
|
||||
public void Invoke(Action action)
|
||||
{
|
||||
_application.Invoke(action);
|
||||
EtoPlatform.Current.Invoke(_application, action);
|
||||
}
|
||||
|
||||
public void InvokeDispatch(Action action)
|
||||
{
|
||||
_application.AsyncInvoke(action);
|
||||
EtoPlatform.Current.AsyncInvoke(_application, action);
|
||||
}
|
||||
|
||||
public T InvokeGet<T>(Func<T> func)
|
||||
{
|
||||
T value = default!;
|
||||
_application.Invoke(() => value = func());
|
||||
EtoPlatform.Current.Invoke(_application, () => value = func());
|
||||
return value;
|
||||
}
|
||||
}
|
@ -48,6 +48,16 @@ public abstract class EtoPlatform
|
||||
application.Run();
|
||||
}
|
||||
|
||||
public virtual void Invoke(Application application, Action action)
|
||||
{
|
||||
application.Invoke(action);
|
||||
}
|
||||
|
||||
public virtual void AsyncInvoke(Application application, Action action)
|
||||
{
|
||||
application.AsyncInvoke(action);
|
||||
}
|
||||
|
||||
public virtual void SetContainerSize(Window window, Control container, Size size, int padding)
|
||||
{
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user