I am creating my first OS X Application through Xamarin and i have a windowless app, so it's just a icon in the menu bar with an icon and a menu to close the app. I want to close the app through the menuitem with the following code:
public override void DidFinishLaunching (NSNotification notification)
{
var statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(30f);
statusItem.Image = NSImage.ImageNamed("os_logo.png");
statusItem.HighlightMode = true;
var menu = new NSMenu ();
// Closing the app
var quitItem = new NSMenuItem ("Sluit OPEN.dev", "q", delegate {
NSApplication.SharedApplication.Terminate(NSApplication.SharedApplication);
});
menu.AddItem (quitItem);
NSApplication.SharedApplication.MainMenu = menu;
statusItem.Menu = menu;
}
But the icon won't disappear/the app won't close.
Does somebody have a solution for this?