Browse Source

Android - call base dispatch key event before called toplevel's override (#16969)

* android - call base dispatch key event before called toplevel's override

* android - handle keyevent in avalonia before calling base DispatchKeyEvent

---------

Co-authored-by: Benedikt Stebner <Gillibald@users.noreply.github.com>
pull/17021/head
Emmanuel Hansen 1 year ago
committed by GitHub
parent
commit
282c0a60d8
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      src/Android/Avalonia.Android/AvaloniaView.cs
  2. 6
      src/Android/Avalonia.Android/Platform/Specific/Helpers/AndroidKeyboardEventsHelper.cs

4
src/Android/Avalonia.Android/AvaloniaView.cs

@ -66,7 +66,9 @@ namespace Avalonia.Android
public override bool DispatchKeyEvent(KeyEvent? e) public override bool DispatchKeyEvent(KeyEvent? e)
{ {
return _view.View.DispatchKeyEvent(e); if (!_view.View.DispatchKeyEvent(e))
return base.DispatchKeyEvent(e);
return true;
} }
[SupportedOSPlatform("android24.0")] [SupportedOSPlatform("android24.0")]

6
src/Android/Avalonia.Android/Platform/Specific/Helpers/AndroidKeyboardEventsHelper.cs

@ -70,6 +70,8 @@ namespace Avalonia.Android.Platform.Specific.Helpers
_view.Input?.Invoke(rawKeyEvent); _view.Input?.Invoke(rawKeyEvent);
bool handled = rawKeyEvent.Handled;
if ((e.Action == KeyEventActions.Down && e.UnicodeChar >= 32) if ((e.Action == KeyEventActions.Down && e.UnicodeChar >= 32)
|| unicodeTextInput != null) || unicodeTextInput != null)
{ {
@ -80,6 +82,8 @@ namespace Avalonia.Android.Platform.Specific.Helpers
unicodeTextInput ?? Convert.ToChar(e.UnicodeChar).ToString() unicodeTextInput ?? Convert.ToChar(e.UnicodeChar).ToString()
); );
_view.Input?.Invoke(rawTextEvent); _view.Input?.Invoke(rawTextEvent);
handled = handled || rawTextEvent.Handled;
} }
if (e.Action == KeyEventActions.Up) if (e.Action == KeyEventActions.Up)
@ -90,7 +94,7 @@ namespace Avalonia.Android.Platform.Specific.Helpers
} }
callBase = false; callBase = false;
return false; return handled;
} }
private static RawInputModifiers GetModifierKeys(KeyEvent e) private static RawInputModifiers GetModifierKeys(KeyEvent e)

Loading…
Cancel
Save