Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@chamons

chamons/main.cs Secret

Created October 15, 2018 15:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chamons/c1abb5476f44a2ea26fadefcbf486ec9 to your computer and use it in GitHub Desktop.
Save chamons/c1abb5476f44a2ea26fadefcbf486ec9 to your computer and use it in GitHub Desktop.
public class CustomNSApplication : NSApplication
{
public CustomNSApplication (IntPtr handle) : base (handle) { }
public override void SendEvent (NSEvent theEvent)
{
base.SendEvent (theEvent);
System.Console.WriteLine ("SendEvent");
}
}
static class MainClass
{
[DllImport ("/usr/lib/libobjc.dylib", EntryPoint = "objc_msgSend")]
public extern static IntPtr IntPtr_objc_msgSend (IntPtr receiver, IntPtr selector);
static void Main (string[] args)
{
NSApplication.Init ();
var appClassHandle = Class.GetHandle (typeof (CustomNSApplication));
var selector = new Selector ("sharedApplication");
var nsappHandle = IntPtr_objc_msgSend (appClassHandle, selector.Handle);
var customNSApplication = new CustomNSApplication (nsappHandle);
NSApplication.Main (args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment