Cauldron/Cauldron.Macos/AppDelegate.cs

46 lines
999 B
C#
Raw Normal View History

2023-07-19 22:09:25 +00:00
using AppKit;
2023-07-19 19:30:39 +00:00
using Foundation;
2023-07-21 20:11:56 +00:00
namespace Cauldron.Macos;
2023-07-19 19:30:39 +00:00
[Register("AppDelegate")]
2023-07-19 22:09:25 +00:00
public partial class AppDelegate : NSApplicationDelegate
2023-07-19 19:30:39 +00:00
{
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
}
2023-07-19 22:09:25 +00:00
partial void RunScriptMenuItemClicked(AppKit.NSMenuItem sender)
{
ScriptRunner.RunScript(
NSApplication.SharedApplication.KeyWindow.WindowController
as MainWindow);
}
2023-07-21 22:21:13 +00:00
partial void NewTabMenuItemClicked(AppKit.NSMenuItem sender)
{
(NSApplication.SharedApplication.KeyWindow.WindowController
as MainWindow)
.CreateNewTab();
}
2023-07-19 22:09:25 +00:00
[Action("validateMenuItem:")]
public bool ValidateMenuItem(AppKit.NSMenuItem sender)
{
2023-07-21 22:21:13 +00:00
if (sender.Title is "Run Script" or "New Tab")
return NSApplication.SharedApplication.KeyWindow != null;
return false;
2023-07-19 22:09:25 +00:00
}
2023-07-19 19:30:39 +00:00
}