Skip to content

Commit

Permalink
fix: Ensure the Uno WindowHost is always focused to capture keyboard …
Browse files Browse the repository at this point in the history
…events
  • Loading branch information
MartinZikmund committed Oct 24, 2023
1 parent 3c5d740 commit db6f700
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Uno.UI.Runtime.Skia.Wpf/UI/Controls/UnoWpfWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Uno.UI.Runtime.Skia.Wpf.UI.Controls;
internal class UnoWpfWindow : WpfWindow
{
private readonly WinUI.Window _winUIWindow;
private readonly UnoWpfWindowHost _host;
private bool _isVisible;

public UnoWpfWindow(WinUI.Window winUIWindow)
Expand All @@ -31,7 +32,7 @@ public UnoWpfWindow(WinUI.Window winUIWindow)
Height = (int)preferredWindowSize.Height;
}

Content = new UnoWpfWindowHost(this, winUIWindow);
Content = _host = new UnoWpfWindowHost(this, winUIWindow);

Closing += OnClosing;
Activated += OnActivated;
Expand Down Expand Up @@ -65,8 +66,11 @@ private void OnClosing(object? sender, CancelEventArgs e)
private void OnDeactivated(object? sender, EventArgs e) =>
_winUIWindow?.OnNativeActivated(Windows.UI.Core.CoreWindowActivationState.Deactivated);

private void OnActivated(object? sender, EventArgs e) =>
private void OnActivated(object? sender, EventArgs e)
{
_winUIWindow.OnNativeActivated(Windows.UI.Core.CoreWindowActivationState.PointerActivated);
_host.Focus();
}

private void OnStateChanged(object? sender, EventArgs e)
{
Expand Down

0 comments on commit db6f700

Please sign in to comment.