diff options
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; } |