Cauldron/Cauldron.Macos/AppDelegate.cs
2023-07-21 15:21:13 -07:00

46 lines
999 B
C#

using AppKit;
using Foundation;
namespace Cauldron.Macos;
[Register("AppDelegate")]
public partial class AppDelegate : NSApplicationDelegate
{
public AppDelegate()
{
}
public override void DidFinishLaunching(NSNotification notification)
{
// Insert code here to initialize your application
}
public override void WillTerminate(NSNotification notification)
{
// Insert code here to tear down your application
}
partial void RunScriptMenuItemClicked(AppKit.NSMenuItem sender)
{
ScriptRunner.RunScript(
NSApplication.SharedApplication.KeyWindow.WindowController
as MainWindow);
}
partial void NewTabMenuItemClicked(AppKit.NSMenuItem sender)
{
(NSApplication.SharedApplication.KeyWindow.WindowController
as MainWindow)
.CreateNewTab();
}
[Action("validateMenuItem:")]
public bool ValidateMenuItem(AppKit.NSMenuItem sender)
{
if (sender.Title is "Run Script" or "New Tab")
return NSApplication.SharedApplication.KeyWindow != null;
return false;
}
}