Browse Source

Fixed formatted value validation

flabbet 1 year ago
parent
commit
05fd3af530

+ 1 - 0
src/PixiEditor/Views/Dock/ColorPickerDockView.axaml.cs

@@ -22,6 +22,7 @@ public partial class ColorPickerDockView : UserControl
         foreach (var textBox in textBoxes)
         foreach (var textBox in textBoxes)
         {
         {
             var existingBehaviors = Interaction.GetBehaviors(textBox);
             var existingBehaviors = Interaction.GetBehaviors(textBox);
+            if(existingBehaviors.Any(x => x is GlobalShortcutFocusBehavior)) continue;
             bool attach = false;
             bool attach = false;
             if (existingBehaviors == null)
             if (existingBehaviors == null)
             {
             {

+ 1 - 11
src/PixiEditor/Views/Input/NumberInput.cs

@@ -137,7 +137,6 @@ internal partial class NumberInput : TextBox
     static NumberInput()
     static NumberInput()
     {
     {
         ValueProperty.Changed.Subscribe(OnValueChanged);
         ValueProperty.Changed.Subscribe(OnValueChanged);
-        FormattedValueProperty.Changed.Subscribe(FormattedValueChanged);
     }
     }
 
 
     public NumberInput()
     public NumberInput()
@@ -240,7 +239,7 @@ internal partial class NumberInput : TextBox
 
 
         behavior.Bind(TextBoxFocusBehavior.ConfirmOnEnterProperty, confirmOnEnterBinding);
         behavior.Bind(TextBoxFocusBehavior.ConfirmOnEnterProperty, confirmOnEnterBinding);
     }
     }
-
+    
     private static double CoerceValue(AvaloniaObject o, double value)
     private static double CoerceValue(AvaloniaObject o, double value)
     {
     {
         double min = (double)o.GetValue(MinProperty);
         double min = (double)o.GetValue(MinProperty);
@@ -330,15 +329,6 @@ internal partial class NumberInput : TextBox
         return value is sbyte or byte or short or ushort or int or uint or long or ulong or float or double or decimal;
         return value is sbyte or byte or short or ushort or int or uint or long or ulong or float or double or decimal;
     }
     }
 
 
-    private static void FormattedValueChanged(AvaloniaPropertyChangedEventArgs<string> e)
-    {
-        NumberInput input = (NumberInput)e.Sender;
-        if (ContainsInvalidCharacter(e.NewValue.Value))
-        {
-            input.FormattedValue = e.OldValue.Value;
-        }
-    }
-
     private static bool ContainsInvalidCharacter(string text)
     private static bool ContainsInvalidCharacter(string text)
     {
     {
         if (text == null)
         if (text == null)