Skip to content

Commit

Permalink
fix: change how we handle the keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
spouliot committed Nov 5, 2024
1 parent c260496 commit 5b7c0fc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Uno.UI.Runtime.Skia.MacOS/MacOSWindowHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Windows.UI.Core;
using Windows.UI.Input;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Input;

using Window = Microsoft.UI.Xaml.Window;

Expand Down Expand Up @@ -278,8 +279,7 @@ private static int OnRawKeyDown(nint handle, VirtualKey key, VirtualKeyModifiers
}
var args = CreateArgs(key, mods, scanCode, unicode);
keyDown.Invoke(window!, args);
// we tell macOS it's always handled as WinUI does not mark as handled some keys that would make it beep in common cases
return 1;
return FocusManager.GetFocusedElement() == null ? 0 : 1;
}
catch (Exception e)
{
Expand All @@ -306,7 +306,7 @@ private static int OnRawKeyUp(nint handle, VirtualKey key, VirtualKeyModifiers m
}
var args = CreateArgs(key, mods, scanCode, unicode);
keyUp.Invoke(window!, args);
return args.Handled ? 1 : 0;
return 1;
}
catch (Exception e)
{
Expand Down Expand Up @@ -414,8 +414,8 @@ internal static unsafe int OnMouseEvent(nint handle, NativeMouseEventData* data)
}

mouseEvent(window, BuildPointerArgs(*data));
// let the window be activated (becoming the keyWindow) when clicked
return data->EventType == NativeMouseEvents.Down ? 0 : 1;
// always let the native side know about the mouse events, e.g. setting keyWindow, embedded native controls
return 0;
}
catch (Exception e)
{
Expand Down

0 comments on commit 5b7c0fc

Please sign in to comment.