diff options
author | Alex Corrado <alexc@xamarin.com> | 2013-10-26 02:30:52 +0400 |
---|---|---|
committer | Alex Corrado <alexc@xamarin.com> | 2013-10-26 02:30:52 +0400 |
commit | 8c1798eab83c51a0ad37b3de4abe5355a13dae9a (patch) | |
tree | 5bc7c8238f84711ec5871ba51759c584d49f66ba /Xwt.Mac | |
parent | e0c956260ff860d9f57127efffb722f338d39586 (diff) |
[Mac] DialogBackend: End the modal loop if the dialog is closed with the close button
Diffstat (limited to 'Xwt.Mac')
-rw-r--r-- | Xwt.Mac/Xwt.Mac/DialogBackend.cs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Xwt.Mac/Xwt.Mac/DialogBackend.cs b/Xwt.Mac/Xwt.Mac/DialogBackend.cs index 1afd1b74..dc1ec092 100644 --- a/Xwt.Mac/Xwt.Mac/DialogBackend.cs +++ b/Xwt.Mac/Xwt.Mac/DialogBackend.cs @@ -28,6 +28,7 @@ using System.Linq; using Xwt.Backends; using System.Collections.Generic; using MonoMac.AppKit; +using MonoMac.Foundation; namespace Xwt.Mac { @@ -41,6 +42,8 @@ namespace Xwt.Mac Dictionary<DialogButton,Button> buttons = new Dictionary<DialogButton, Button> (); WidgetSpacing buttonBoxPadding = new WidgetSpacing (12, 6, 12, 12); + bool modalSessionRunning; + public DialogBackend () { } @@ -55,6 +58,14 @@ namespace Xwt.Mac }; buttonBoxView = ((ViewBackend)buttonBox.GetBackend ()).Widget; ContentView.AddSubview (buttonBoxView); + + WillClose += HandleWillClose; + } + + void HandleWillClose (object sender, EventArgs e) + { + if (modalSessionRunning) + EndLoop (); } public override void LayoutWindow () @@ -124,11 +135,13 @@ namespace Xwt.Mac public void RunLoop (IWindowFrameBackend parent) { Visible = true; + modalSessionRunning = true; NSApplication.SharedApplication.RunModalForWindow (this); } public void EndLoop () { + modalSessionRunning = false; NSApplication.SharedApplication.StopModal (); } |