diff options
author | CartBlanche <savagesoftware@gmail.com> | 2020-01-31 19:39:06 +0300 |
---|---|---|
committer | CartBlanche <savagesoftware@gmail.com> | 2020-02-11 23:02:27 +0300 |
commit | fa098f63c61f161acc83eb6f149237856ec56c90 (patch) | |
tree | 6fe478c8aa5cbe53d5528bb9044fe93d04f1d648 /Xamarin.PropertyEditing.Mac/Controls | |
parent | cc3fa9016757731c798552f52a79350d6af46a51 (diff) |
[Mac] Allow Ctrl+Shift+i to display the Property Button's menu.
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls')
-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; } |