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:
authorJose Medrano <josmed@microsoft.com>2020-07-02 13:39:33 +0300
committerJose Medrano <josmed@microsoft.com>2020-07-02 13:39:33 +0300
commit291eaa285c91ef466d1fb2250f7f1a4140bcc8db (patch)
treee3ec28ecb1df42de5d76586cf32f1b375a641934
parent8b05145b42e613b833ac69da84a75b29204380e5 (diff)
Removes current hack to focus caller view on calling a RunModalForWindowremoves-focus-hack
-rw-r--r--Xamarin.PropertyEditing.Mac/CocoaHelpers.cs17
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/CollectionInlineEditorControl.cs13
2 files changed, 10 insertions, 20 deletions
diff --git a/Xamarin.PropertyEditing.Mac/CocoaHelpers.cs b/Xamarin.PropertyEditing.Mac/CocoaHelpers.cs
index fa25e5b..0c18691 100644
--- a/Xamarin.PropertyEditing.Mac/CocoaHelpers.cs
+++ b/Xamarin.PropertyEditing.Mac/CocoaHelpers.cs
@@ -30,22 +30,11 @@ namespace Xamarin.PropertyEditing.Mac
{
public static class CocoaHelpers
{
- public static void RunModalForWindow (NSWindow window, NSView controlToFocusWhenWindowClosed, Action<NSModalResponse> responseHandler = null, int defaultDelayTime = 100)
+ public static NSModalResponse RunModalForWindow (NSWindow window, NSWindow parent)
{
- //HACK: Because VS4Mac is a GTK application try force set to NSApplication.SharedApplication.RunModalForWindow
- //breaks the current focused window. Try only focus the ID is not enought, because our IDE on get focus (gtk) will override the current
- //focused element, then launch a task to allow the IDE to get the focus and wait for synchcontext to focus the correct view.
- var parentWindow = NSApplication.SharedApplication.KeyWindow;
-
var result = (NSModalResponse)(int)NSApplication.SharedApplication.RunModalForWindow (window);
-
- //after run modal our FocusedWindow is null, we set the parent again
- parentWindow?.MakeKeyAndOrderFront (parentWindow);
-
- System.Threading.Tasks.Task.Delay (defaultDelayTime).ContinueWith (t => {
- responseHandler?.Invoke (result);
- parentWindow?.MakeFirstResponder (controlToFocusWhenWindowClosed);
- }, System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext ());
+ parent?.MakeKeyAndOrderFront (parent);
+ return result;
}
}
}
diff --git a/Xamarin.PropertyEditing.Mac/Controls/CollectionInlineEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/CollectionInlineEditorControl.cs
index 9eb7cad..14cd84e 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/CollectionInlineEditorControl.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/CollectionInlineEditorControl.cs
@@ -29,12 +29,13 @@ namespace Xamarin.PropertyEditing.Mac
Appearance = EffectiveAppearance
};
- CocoaHelpers.RunModalForWindow (w, this.openCollection, responseHandler: result => {
- if (result != NSModalResponse.OK)
- ViewModel.CancelCommand.Execute (null);
- else
- ViewModel.CommitCommand.Execute (null);
- });
+ var parentWindow = Window;
+
+ var result = CocoaHelpers.RunModalForWindow (w, parentWindow);
+ if (result != NSModalResponse.OK)
+ ViewModel.CancelCommand.Execute (null);
+ else
+ ViewModel.CommitCommand.Execute (null);
};
AddSubview (this.openCollection);