diff options
author | Bret Johnson <bret.johnson@microsoft.com> | 2022-03-17 07:23:25 +0300 |
---|---|---|
committer | Bret Johnson <bret.johnson@microsoft.com> | 2022-03-17 07:23:25 +0300 |
commit | a2e92bf834987d6e428c53cf8db31a93c04a3151 (patch) | |
tree | 9a82069c96aeda99042df1c8f0926ad9fedbd99a /Xamarin.PropertyEditing.Windows/PropertyPresenter.cs | |
parent | 6359edaa5c81a0d1697a1ad36807b74388f8ebb2 (diff) |
Use PreviewKeyDown for Ctrl+Space to show menu
Ctrl+Space is the keyboard short that can
be used to show the property editor menu
for a property (with options like Reset,
Convert to Local Value, etc.). Previously, that
was detected via a KeyBinding in XAML, which
worked for text boxes but not controls like
checkbox and button, which handle the
key down event themselves. Now we
use PreviewKeyDown instead, handling that
in C# code, to work for all control
types.
Fixes AB#1491229
Diffstat (limited to 'Xamarin.PropertyEditing.Windows/PropertyPresenter.cs')
-rw-r--r--[-rwxr-xr-x] | Xamarin.PropertyEditing.Windows/PropertyPresenter.cs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Xamarin.PropertyEditing.Windows/PropertyPresenter.cs b/Xamarin.PropertyEditing.Windows/PropertyPresenter.cs index 4cf1813..af7dbbc 100755..100644 --- a/Xamarin.PropertyEditing.Windows/PropertyPresenter.cs +++ b/Xamarin.PropertyEditing.Windows/PropertyPresenter.cs @@ -6,6 +6,7 @@ using System.Windows.Automation; using System.Windows.Automation.Peers; using System.Windows.Controls; using System.Windows.Controls.Primitives; +using System.Windows.Input; using System.Windows.Media; using Xamarin.PropertyEditing.ViewModels; @@ -112,6 +113,11 @@ namespace Xamarin.PropertyEditing.Windows this.variationRow = (RowDefinition) GetTemplateChild ("variationRow"); this.variationsList = GetTemplateChild ("variationsList") as ItemsControl; + + this.propertyButton = (PropertyButton) GetTemplateChild ("propertyButton"); + + this.propertyContainer = (Border) GetTemplateChild ("propertyContainer"); + this.propertyContainer.AddHandler (Border.PreviewKeyDownEvent, new KeyEventHandler (PropertyContainer_PreviewKeyDown)); } protected override AutomationPeer OnCreateAutomationPeer () @@ -155,10 +161,22 @@ namespace Xamarin.PropertyEditing.Windows } } + private void PropertyContainer_PreviewKeyDown (object sender, KeyEventArgs e) + { + var isModifierControl = Keyboard.Modifiers == ModifierKeys.Control; + + if (e.Key == Key.Space && isModifierControl) { + propertyButton.ShowMenu (); + e.Handled = true; + } + } + private PropertyViewModel pvm; private ButtonBase addButton, removeButton; private RowDefinition variationRow; private ItemsControl variationsList; + private Border propertyContainer; + private PropertyButton propertyButton; private void OnLoaded (object sender, RoutedEventArgs e) { |