diff options
author | CartBlanche <savagesoftware@gmail.com> | 2019-07-10 19:33:17 +0300 |
---|---|---|
committer | CartBlanche <savagesoftware@gmail.com> | 2019-07-31 14:31:17 +0300 |
commit | d078ccbbdcd671c4d8eeae877a823eda5d43dd15 (patch) | |
tree | 2a4f30865177d5b64bf1e9230903994eb563be82 /Xamarin.PropertyEditing.Mac | |
parent | ca208821737368fca17fec185ed66de57b4ad40e (diff) |
[Mac] Fix so that when menu is popped up, associated controlled is focused.
Diffstat (limited to 'Xamarin.PropertyEditing.Mac')
6 files changed, 26 insertions, 21 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/BasePathEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BasePathEditorControl.cs index dde6136..ddf4a2c 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BasePathEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BasePathEditorControl.cs @@ -91,6 +91,7 @@ namespace Xamarin.PropertyEditing.Mac private void BrowsePathButton_Activated (object sender, EventArgs e) {
+ Window.MakeFirstResponder (this.currentTextField);
this.panel.BeginSheet (this.Window, HandleAction);
}
diff --git a/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs index 19b4750..af1be83 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs @@ -19,6 +19,7 @@ namespace Xamarin.PropertyEditing.Mac if (!Popover.Shown) { Popover.Show (new CGRect (26, this.Frame.Height / 2 - 2, 2, 2), this, NSRectEdge.MinYEdge); + Window.MakeFirstResponder (this); Window.MakeFirstResponder (Popover); } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/CollectionInlineEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/CollectionInlineEditorControl.cs index 54056ac..abbd9fa 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/CollectionInlineEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/CollectionInlineEditorControl.cs @@ -25,6 +25,7 @@ namespace Xamarin.PropertyEditing.Mac }; this.openCollection.Activated += (o, e) => { + Window.MakeFirstResponder (this.openCollection); CollectionEditorWindow.EditCollection (EffectiveAppearance, HostResources, ViewModel); }; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs index 90ca577..7e8b6bc 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs @@ -142,6 +142,8 @@ namespace Xamarin.PropertyEditing.Mac }); } + FocusClickedRow (); + var menuOrigin = this.Superview.ConvertPointToView (new CGPoint (Frame.Location.X - 1, Frame.Location.Y + Frame.Size.Height + 4), null); var popupMenuEvent = NSEvent.MouseEvent (NSEventType.LeftMouseDown, menuOrigin, (NSEventModifierMask)0x100, 0, this.Window.WindowNumber, this.Window.GraphicsContext, 0, 1, 1); @@ -149,6 +151,25 @@ namespace Xamarin.PropertyEditing.Mac NSMenu.PopUpContextMenu (popUpContextMenu, popupMenuEvent, this); } + private void FocusClickedRow () + { + if (Superview != null) { + MakeFocusableKeyViewFirstResponder (Superview.Subviews); + } + } + + private void MakeFocusableKeyViewFirstResponder (NSView[] subViews) + { + foreach (NSView item in subViews) { + if (item.CanBecomeKeyView) { + Window.MakeFirstResponder (item); + break; + } else { + MakeFocusableKeyViewFirstResponder (item.Subviews); + } + } + } + private void ToggleFocusImage (bool focused = false) { if (this.viewModel != null) { diff --git a/Xamarin.PropertyEditing.Mac/Controls/FilePathEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/FilePathEditorControl.cs index 32c7d7f..1a28703 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/FilePathEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/FilePathEditorControl.cs @@ -23,6 +23,7 @@ namespace Xamarin.PropertyEditing.Mac protected override void OnRevealPathButtonActivated (object sender, EventArgs e) { + Window.MakeFirstResponder (this.currentTextField); if (File.Exists (this.currentTextField.StringValue)) { NSWorkspace.SharedWorkspace.SelectFile (this.currentTextField.StringValue, string.Empty); } diff --git a/Xamarin.PropertyEditing.Mac/Controls/TypeEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/TypeEditorControl.cs index b7e68d3..44a61a8 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/TypeEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/TypeEditorControl.cs @@ -92,11 +92,6 @@ namespace Xamarin.PropertyEditing.Mac private readonly NSButton selectType; private readonly NSLayoutConstraint buttonConstraint; - private void OnCreateInstanceExecutableChanged (object sender, EventArgs e) - { - UpdateCreateInstanceCommand (); - } - private void OnTypeRequested (object sender, TypeRequestedEventArgs e) { e.SelectedType = e.RequestAt (HostResources, this.selectType, ViewModel.AssignableTypes); @@ -120,23 +115,8 @@ namespace Xamarin.PropertyEditing.Mac private void OnSelectPressed (object sender, EventArgs e) { + Window.MakeFirstResponder (this.selectType); ViewModel.SelectTypeCommand.Execute (null); } - - private class PopoverDelegate<T> - : NSPopoverDelegate - { - public PopoverDelegate (TaskCompletionSource<T> tcs) - { - this.tcs = tcs; - } - - public override void WillClose (NSNotification notification) - { - this.tcs.TrySetCanceled (); - } - - private readonly TaskCompletionSource<T> tcs; - } } } |