Browse Source

Fixed removing logical focus from NumberInput

flabbet 4 years ago
parent
commit
20b3bfedb4

+ 13 - 1
PixiEditor/Helpers/Behaviours/TextBoxFocusBehavior.cs

@@ -54,7 +54,19 @@ namespace PixiEditor.Helpers.Behaviours
             }
 
             ConvertValue();
-            AssociatedObject.MoveFocus(new TraversalRequest(FocusNavigationDirection.Down));
+            RemoveFocus();
+        }
+
+        private void RemoveFocus()
+        {
+            FrameworkElement parent = (FrameworkElement)AssociatedObject.Parent;
+            while (parent != null && parent is IInputElement && !((IInputElement)parent).Focusable)
+            {
+                parent = (FrameworkElement)parent.Parent;
+            }
+
+            DependencyObject scope = FocusManager.GetFocusScope(AssociatedObject);
+            FocusManager.SetFocusedElement(scope, parent);
         }
 
         private void AssociatedObjectGotKeyboardFocus(

+ 0 - 1
PixiEditor/Views/UserControls/NumberInput.xaml

@@ -16,6 +16,5 @@
                 <behaviours:TextBoxFocusBehavior />
             </i:Interaction.Behaviors>
         </TextBox>
-        <TextBox Width="0" Height="0" />
     </Grid>
 </UserControl>