Browse Source

Fixed new viewport focus

flabbet 1 year ago
parent
commit
526507cf89
1 changed files with 7 additions and 0 deletions
  1. 7 0
      src/PixiEditor/Views/Main/ViewportControls/Viewport.axaml.cs

+ 7 - 0
src/PixiEditor/Views/Main/ViewportControls/Viewport.axaml.cs

@@ -12,6 +12,7 @@ using PixiEditor.ViewModels;
 using PixiEditor.Views.Visuals;
 using PixiEditor.DrawingApi.Core;
 using PixiEditor.DrawingApi.Core.Numerics;
+using PixiEditor.Helpers.Behaviours;
 using PixiEditor.Helpers.UI;
 using PixiEditor.Models.Controllers.InputDevice;
 using PixiEditor.Models.DocumentModels;
@@ -308,6 +309,7 @@ internal partial class Viewport : UserControl, INotifyPropertyChanged
         Scene.SizeChanged += OnMainImageSizeChanged;
         Loaded += OnLoad;
         Unloaded += OnUnload;
+        Scene.AttachedToVisualTree += OnAttachedToVisualTree;
 
         //TODO: It's weird that I had to do it this way, right click didn't raise Image_MouseUp otherwise.
         viewportGrid.AddHandler(PointerReleasedEvent, Image_MouseUp, RoutingStrategies.Tunnel);
@@ -317,6 +319,11 @@ internal partial class Viewport : UserControl, INotifyPropertyChanged
         Scene.PointerEntered += (sender, args) => IsOverCanvas = true;
     }
 
+    private void OnAttachedToVisualTree(object? sender, VisualTreeAttachmentEventArgs e)
+    {
+        TextBoxFocusBehavior.FallbackFocusElement.Focus();
+    }
+
     public Scene Scene => scene;
 
     private void ForceRefreshFinalImage()