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/Controls/Custom | |
parent | ca208821737368fca17fec185ed66de57b4ad40e (diff) |
[Mac] Fix so that when menu is popped up, associated controlled is focused.
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls/Custom')
-rw-r--r-- | Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs | 21 |
1 files changed, 21 insertions, 0 deletions
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) { |