-
-
Save chamons/15ffc5c8c62386aea9d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using AppKit; | |
using Foundation; | |
namespace TestMenu | |
{ | |
public partial class ViewController : NSViewController | |
{ | |
public ViewController(IntPtr handle) : base(handle) | |
{ | |
} | |
public override void ViewDidLoad() | |
{ | |
base.ViewDidLoad(); | |
var menu = NSApplication.SharedApplication.Menu; | |
var menuDelegate = menu.Delegate; | |
if (menuDelegate == null) | |
{ | |
MyMenuDelegate.Me = new MyMenuDelegate(); | |
menu.Delegate = MyMenuDelegate.Me; | |
} | |
} | |
private class MyMenuDelegate : NSMenuDelegate | |
{ | |
internal static MyMenuDelegate Me { get; set; } | |
#region implemented abstract members of NSMenuDelegate | |
public override void MenuWillHighlightItem(NSMenu menu, NSMenuItem item) | |
{ | |
} | |
#endregion | |
public override bool HasKeyEquivalentForEvent(NSMenu menu, NSEvent theEvent, NSObject target, ObjCRuntime.Selector action) | |
{ | |
return false; | |
} | |
} | |
public override NSObject RepresentedObject | |
{ | |
get | |
{ | |
return base.RepresentedObject; | |
} | |
set | |
{ | |
base.RepresentedObject = value; | |
// Update the view, if already loaded. | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment