diff options
author | Eric Maupin <ermaup@microsoft.com> | 2020-02-14 00:28:14 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-14 00:28:14 +0300 |
commit | 3f1add83acfb543b99d2f9ed4b2e61810c14f976 (patch) | |
tree | 6fe478c8aa5cbe53d5528bb9044fe93d04f1d648 /Xamarin.PropertyEditing.Mac | |
parent | cc3fa9016757731c798552f52a79350d6af46a51 (diff) | |
parent | fa098f63c61f161acc83eb6f149237856ec56c90 (diff) |
Merge pull request #704 from xamarin/dominique-CtrlSpaceToFirePropertyButton
[Mac] Allow Ctrl+Shift+i to display the Property Button's menu.
Diffstat (limited to 'Xamarin.PropertyEditing.Mac')
-rw-r--r-- | Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs | 2 | ||||
-rw-r--r-- | Xamarin.PropertyEditing.Mac/Controls/PropertyContainer.cs | 33 |
2 files changed, 34 insertions, 1 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs index 0070f6c..28d656f 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs @@ -84,7 +84,7 @@ namespace Xamarin.PropertyEditing.Mac private readonly IHostResourceProvider hostResources; - private void PopUpContextMenu () + internal void PopUpContextMenu () { if (this.popUpContextMenu == null) { this.popUpContextMenu = new NSMenu (); diff --git a/Xamarin.PropertyEditing.Mac/Controls/PropertyContainer.cs b/Xamarin.PropertyEditing.Mac/Controls/PropertyContainer.cs index 712b1bc..73a7f5b 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/PropertyContainer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/PropertyContainer.cs @@ -1,4 +1,5 @@ using System; +using System.Threading; using AppKit; namespace Xamarin.PropertyEditing.Mac @@ -57,6 +58,38 @@ namespace Xamarin.PropertyEditing.Mac } } + public override bool PerformKeyEquivalent (NSEvent theEvent) + { + if (theEvent.KeyCode == (ushort)NSKey.I + && (theEvent.ModifierFlags & (NSEventModifierMask.ShiftKeyMask | NSEventModifierMask.ControlKeyMask)) + == (NSEventModifierMask.ShiftKeyMask | NSEventModifierMask.ControlKeyMask)) { + if (theEvent.Window.FirstResponder is NSView fr) { + var propertyContainer = FindPropertyContainer (fr); // Recursive on SuperView, up the chain + if (propertyContainer != null) { + SynchronizationContext.Current.Post (s => { + propertyContainer.PropertyButton.PopUpContextMenu (); + }, null); + return true; + } + } + } + + return base.PerformKeyEquivalent (theEvent); + } + + private PropertyContainer FindPropertyContainer (NSView fr) + { + if (fr.Superview != null) { + if (fr.Superview is PropertyContainer propertyContainer) { + return propertyContainer; + } else { + return FindPropertyContainer (fr.Superview); + } + } else { + return null; + } + } + public string Label { get { return this.label.StringValue; } |