Skip to content

Commit

Permalink
chore: Try focus keyup
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Mar 13, 2023
1 parent cbeb9c4 commit 8de962e
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/Uno.UI/UI/Xaml/ApplicationActivity.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,24 @@ public override bool DispatchKeyEvent(KeyEvent e)
{
if (CoreWindow.GetForCurrentThread() is ICoreWindowEvents ownerEvents)
{
ownerEvents.RaiseKeyDown(args);

var routerArgs = new KeyRoutedEventArgs(this, virtualKey)
if (e.Action == KeyEventActions.Down)
{
CanBubbleNatively = false
};
ownerEvents.RaiseKeyDown(args);
}

(FocusManager.GetFocusedElement() as FrameworkElement)?.RaiseEvent(UIElement.KeyDownEvent, routerArgs);
if (FocusManager.GetFocusedElement() is FrameworkElement element)
{
var routedArgs = new KeyRoutedEventArgs(this, virtualKey)
{
CanBubbleNatively = false
};

RoutedEvent routedEvent = e.Action == KeyEventActions.Down ?
UIElement.KeyDownEvent :
UIElement.KeyUpEvent;

element?.RaiseEvent(routedEvent, routedArgs);
}

handled = true;
}
Expand Down

0 comments on commit 8de962e

Please sign in to comment.