Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan McGovern <alan@xamarin.com>2019-03-21 15:37:17 +0300
committerCartBlanche <savagesoftware@gmail.com>2019-06-26 21:12:35 +0300
commit6be4f60fa2d4adf31893c75d8a8ef8ce879b6bd3 (patch)
treee155a6fe00c3c77b48f5addb8d26c4a57ff351ca /Xamarin.PropertyEditing.Mac
parent820c53ae01fa95075fd3990f56a81a30e38e8312 (diff)
[Mac] Handle all scenarios where the window is closed
If we click the ok button then set the response to OK, otherwise every other scenario should be treated as cancelling. This includes presssing Esc,clicking the red traffic light button and also command-W. Make this a Panel again, so 'Esc' works
Diffstat (limited to 'Xamarin.PropertyEditing.Mac')
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/BindingEditor/CreateValueConverterWindow.cs24
1 files changed, 15 insertions, 9 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/BindingEditor/CreateValueConverterWindow.cs b/Xamarin.PropertyEditing.Mac/Controls/BindingEditor/CreateValueConverterWindow.cs
index 6415ae6..e97a9b4 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/BindingEditor/CreateValueConverterWindow.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/BindingEditor/CreateValueConverterWindow.cs
@@ -8,8 +8,13 @@ using Xamarin.PropertyEditing.ViewModels;
namespace Xamarin.PropertyEditing.Mac
{
- internal class CreateValueConverterWindow : NSWindow
+ internal class CreateValueConverterWindow : NSPanel
{
+ new ModalWindowCloseDelegate Delegate {
+ get => (ModalWindowCloseDelegate)base.Delegate;
+ set => base.Delegate = value;
+ }
+
public AddValueConverterViewModel ViewModel { get; }
private NSTextField valueConverterName;
@@ -22,6 +27,7 @@ namespace Xamarin.PropertyEditing.Mac
if (viewModel == null)
throw new ArgumentNullException (nameof (viewModel));
+ Delegate = new ModalWindowCloseDelegate ();
ViewModel = new AddValueConverterViewModel (viewModel.TargetPlatform, viewModel.Target, typetasks);
StyleMask |= NSWindowStyle.Resizable;
@@ -83,7 +89,7 @@ namespace Xamarin.PropertyEditing.Mac
};
buttonDone.Activated += (sender, e) => {
- NSApplication.SharedApplication.StopModalWithCode ((int)NSModalResponse.OK);
+ Delegate.Response = NSModalResponse.OK;
Close ();
};
@@ -105,15 +111,15 @@ namespace Xamarin.PropertyEditing.Mac
}
};
}
+ }
- public override void KeyUp (NSEvent theEvent)
+ public class ModalWindowCloseDelegate : NSWindowDelegate
+ {
+ public NSModalResponse Response { get; set; } = NSModalResponse.Cancel;
+
+ public override void WillClose (NSNotification notification)
{
- if (theEvent.KeyCode == 53) {
- NSApplication.SharedApplication.StopModalWithCode ((int)NSModalResponse.Cancel);
- Close ();
- } else {
- base.KeyUp (theEvent);
- }
+ NSApplication.SharedApplication.StopModalWithCode ((int)Response);
}
}
}