diff --git a/Cauldron.Macos/AppDelegate.cs b/Cauldron.Macos/AppDelegate.cs index 42fb347..f88e289 100644 --- a/Cauldron.Macos/AppDelegate.cs +++ b/Cauldron.Macos/AppDelegate.cs @@ -27,9 +27,19 @@ public partial class AppDelegate : NSApplicationDelegate as MainWindow); } + partial void NewTabMenuItemClicked(AppKit.NSMenuItem sender) + { + (NSApplication.SharedApplication.KeyWindow.WindowController + as MainWindow) + .CreateNewTab(); + } + [Action("validateMenuItem:")] public bool ValidateMenuItem(AppKit.NSMenuItem sender) { - return true; + if (sender.Title is "Run Script" or "New Tab") + return NSApplication.SharedApplication.KeyWindow != null; + + return false; } } diff --git a/Cauldron.Macos/AppDelegate.designer.cs b/Cauldron.Macos/AppDelegate.designer.cs index c7f493b..3d3ef68 100644 --- a/Cauldron.Macos/AppDelegate.designer.cs +++ b/Cauldron.Macos/AppDelegate.designer.cs @@ -11,6 +11,9 @@ namespace Cauldron.Macos { partial class AppDelegate { + [Action ("NewTabMenuItemClicked:")] + partial void NewTabMenuItemClicked (AppKit.NSMenuItem sender); + [Action ("RunScriptMenuItemClicked:")] partial void RunScriptMenuItemClicked (AppKit.NSMenuItem sender); diff --git a/Cauldron.Macos/Main.storyboard b/Cauldron.Macos/Main.storyboard index c11b99e..1e5f87d 100644 --- a/Cauldron.Macos/Main.storyboard +++ b/Cauldron.Macos/Main.storyboard @@ -65,6 +65,11 @@ + + + + + @@ -415,7 +420,6 @@ - @@ -434,11 +438,17 @@ + + + + + + @@ -617,6 +627,7 @@ + diff --git a/Cauldron.Macos/MainWindow.cs b/Cauldron.Macos/MainWindow.cs index 834fe20..0c38bf9 100644 --- a/Cauldron.Macos/MainWindow.cs +++ b/Cauldron.Macos/MainWindow.cs @@ -80,6 +80,16 @@ public partial class MainWindow : NSWindowController this.ScriptCancellationTokenSource?.Cancel(); } + partial void NewTabClicked(AppKit.NSToolbarItem sender) + { + this.CreateNewTab(); + } + + partial void NewTabMenuItemClicked(AppKit.NSMenuItem sender) + { + this.CreateNewTab(); + } + public void SetScriptRunState(bool scriptIsRunning) { if (scriptIsRunning) @@ -91,4 +101,12 @@ public partial class MainWindow : NSWindowController this.RunScriptToolbarButton.Enabled = true; } } + + public void CreateNewTab() + { + MainWindow newWindow = this.Storyboard.InstantiateInitialController() + as MainWindow; + this.Window.AddTabbedWindow(newWindow.Window, NSWindowOrderingMode.Above); + this.Window.SelectNextTab(this); + } } diff --git a/Cauldron.Macos/MainWindow.designer.cs b/Cauldron.Macos/MainWindow.designer.cs index 2947543..cc048d7 100644 --- a/Cauldron.Macos/MainWindow.designer.cs +++ b/Cauldron.Macos/MainWindow.designer.cs @@ -17,6 +17,15 @@ namespace Cauldron.Macos [Action ("BtnRunScriptClicked:")] partial void BtnRunScriptClicked (AppKit.NSToolbarItem sender); + + [Action ("NewTabClicked:")] + partial void NewTabClicked (AppKit.NSToolbarItem sender); + + [Action ("NewTabMenuItemClicked:")] + partial void NewTabMenuItemClicked (AppKit.NSMenuItem sender); + + [Action ("NewTabMenuItemClicked2:")] + partial void NewTabMenuItemClicked2 (AppKit.NSMenuItem sender); void ReleaseDesignerOutlets () {