From 692fd5de60d963f98173b4b97501b745e4589b24 Mon Sep 17 00:00:00 2001 From: Emmanuel Hansen Date: Mon, 26 Jun 2023 08:35:41 +0000 Subject: [PATCH] use current ime selection for deletion --- .../Platform/SkiaPlatform/TopLevelImpl.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs b/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs index 558470c026..ecf0fd1225 100644 --- a/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs +++ b/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs @@ -491,6 +491,7 @@ namespace Avalonia.Android.Platform.SkiaPlatform private readonly EditableWrapper _editable; private bool _commitInProgress; private (int Start, int End)? _composingRegion; + private TextSelection _selection; public AvaloniaInputConnection(TopLevelImpl toplevel, IAndroidInputMethod inputMethod) : base(inputMethod.View, true) { @@ -580,10 +581,9 @@ namespace Avalonia.Android.Platform.SkiaPlatform if (InputMethod.IsActive) { + var selection = _selection; - var selection = InputMethod.Client.Selection; - - InputMethod.Client.Selection = new TextSelection(selection.Start - beforeLength, selection.Start + afterLength); + InputMethod.Client.Selection = new TextSelection(selection.Start - beforeLength, selection.End + afterLength); InputMethod.View.DispatchKeyEvent(new KeyEvent(KeyEventActions.Down, Keycode.ForwardDel)); @@ -593,6 +593,12 @@ namespace Avalonia.Android.Platform.SkiaPlatform return result; } + public override bool SetSelection(int start, int end) + { + _selection = new TextSelection(start, end); + return base.SetSelection(start, end); + } + public override bool PerformEditorAction([GeneratedEnum] ImeAction actionCode) { switch (actionCode)