diff --git a/MacWindows/MacWindows/MasterWindowController.cs b/MacWindows/MacWindows/MasterWindowController.cs index a86e4d46..629a7acb 100644 --- a/MacWindows/MacWindows/MasterWindowController.cs +++ b/MacWindows/MacWindows/MasterWindowController.cs @@ -7,8 +7,7 @@ namespace MacWindows { - public partial class MasterWindowController : NSWindowController - { + public partial class MasterWindowController : NSWindowController, INSWindowDelegate { public MasterWindowController (IntPtr handle) : base (handle) { } @@ -16,15 +15,20 @@ public MasterWindowController (IntPtr handle) : base (handle) public override void WindowDidLoad () { base.WindowDidLoad (); + Window.Delegate = this; + } - Window.DidResize += (sender, e) => { - // Do something as the window is being live resized - }; + [Export ("windowDidResize:")] + public void DidResize (NSNotification notification) + { + // Do something as the window is being live resized + } - Window.DidEndLiveResize += (sender, e) => { - // Do something after the user's finished resizing - // the window - }; + [Export ("windowDidEndLiveResize:")] + public void DidEndLiveResize (NSNotification notification) + { + // Do something after the user's finished resizing + // the window } } } diff --git a/MacWindows/MacWindows/ViewController.cs b/MacWindows/MacWindows/ViewController.cs index 82b68ce3..8cf60d91 100644 --- a/MacWindows/MacWindows/ViewController.cs +++ b/MacWindows/MacWindows/ViewController.cs @@ -5,7 +5,7 @@ namespace MacWindows { - public partial class ViewController : NSViewController + public partial class ViewController : NSViewController, INSWindowDelegate { #region Computed Properties public override NSObject RepresentedObject { @@ -45,6 +45,20 @@ public override void ViewDidLoad () } + [Export ("windowWillClose:")] + public void WillClose (NSNotification notification) + { + // is the window dirty? + if (DocumentEdited) { + var alert = new NSAlert () { + AlertStyle = NSAlertStyle.Critical, + InformativeText = "We need to give the user the ability to save the document here...", + MessageText = "Save Document", + }; + alert.RunModal (); + } + } + public override void ViewWillAppear () { base.ViewWillAppear (); @@ -52,17 +66,7 @@ public override void ViewWillAppear () // Set Window Title this.View.Window.Title = "untitled"; - View.Window.WillClose += (sender, e) => { - // is the window dirty? - if (DocumentEdited) { - var alert = new NSAlert () { - AlertStyle = NSAlertStyle.Critical, - InformativeText = "We need to give the user the ability to save the document here...", - MessageText = "Save Document", - }; - alert.RunModal (); - } - }; + View.Window.Delegate = this; } public override void AwakeFromNib ()