Skip to content

Instantly share code, notes, and snippets.

@chamons

chamons/foo.cs Secret

Created January 2, 2019 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chamons/f5d848a6782382dd9344e2b4be42f0e7 to your computer and use it in GitHub Desktop.
Save chamons/f5d848a6782382dd9344e2b4be42f0e7 to your computer and use it in GitHub Desktop.
using System;
using AppKit;
using Foundation;
namespace SavePanelTest
{
public static class NSSavePanelPatch
{
[System.Runtime.InteropServices.DllImport ("/usr/lib/libobjc.dylib", EntryPoint = "objc_msgSend")]
extern static IntPtr IntPtr_objc_msgSend (IntPtr receiver, IntPtr selector);
public static NSSavePanel GetSavePanel ()
{
return ObjCRuntime.Runtime.GetINativeObject<NSSavePanel> (IntPtr_objc_msgSend (ObjCRuntime.Class.GetHandle ("NSSavePanel"), ObjCRuntime.Selector.GetHandle ("savePanel")), true);
}
}
[Register ("AppDelegate")]
public class AppDelegate : NSApplicationDelegate
{
public override void DidFinishLaunching (NSNotification notification)
{
NSSavePanel panel = NSSavePanelPatch.GetSavePanel ();
panel.RunModal ();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment