Browse Source

Made shortcutbox readonly

Krzysztof Krysiński 6 months ago
parent
commit
bc68df08e8

+ 1 - 0
src/PixiEditor/Views/Shortcuts/KeyCombinationBox.axaml

@@ -16,6 +16,7 @@
                  KeyUp="TextBox_PreviewKeyUp"
                  x:Name="textBox"
                  CaretBrush="Transparent"
+                 IsReadOnly="True"
                  GotFocus="TextBox_GotKeyboardFocus"
                  LostFocus="TextBox_LostKeyboardFocus">
             <TextBox.Styles>

+ 8 - 5
src/PixiEditor/Views/Shortcuts/KeyCombinationBox.axaml.cs

@@ -29,8 +29,9 @@ internal partial class KeyCombinationBox : UserControl
 
     public event EventHandler<KeyCombination> KeyCombinationChanged;
 
-    public static readonly StyledProperty<KeyCombination> DefaultCombinationProperty = AvaloniaProperty.Register<KeyCombinationBox, KeyCombination>(
-        nameof(DefaultCombination));
+    public static readonly StyledProperty<KeyCombination> DefaultCombinationProperty =
+        AvaloniaProperty.Register<KeyCombinationBox, KeyCombination>(
+            nameof(DefaultCombination));
 
     public KeyCombination DefaultCombination
     {
@@ -81,7 +82,6 @@ internal partial class KeyCombinationBox : UserControl
         if (GetModifier(e.Key) is { } modifier)
         {
             currentCombination = currentCombination with { Modifiers = currentCombination.Modifiers ^ modifier };
-            UpdateText();
         }
         else
         {
@@ -90,6 +90,7 @@ internal partial class KeyCombinationBox : UserControl
         }
 
         UpdateButton();
+        UpdateText();
     }
 
     private void TextBox_GotKeyboardFocus(object sender, GotFocusEventArgs e)
@@ -127,7 +128,9 @@ internal partial class KeyCombinationBox : UserControl
         }
     }
 
-    private void UpdateText() => textBox.Text = currentCombination != default ? currentCombination.ToString() : new LocalizedString("NONE_SHORTCUT");
+    private void UpdateText() => textBox.Text = currentCombination != default
+        ? currentCombination.ToString()
+        : new LocalizedString("NONE_SHORTCUT");
 
     private void UpdateButton()
     {
@@ -135,7 +138,7 @@ internal partial class KeyCombinationBox : UserControl
         if (textBox.IsFocused)
         {
             button.IsEnabled = true;
-            button.Content = "\ud83d\uddd9";
+            button.Content = "\u2715";
         }
         else if (KeyCombination != DefaultCombination)
         {