diff --git a/src/Windows/Avalonia.Win32/Input/Imm32InputMethod.cs b/src/Windows/Avalonia.Win32/Input/Imm32InputMethod.cs index 05074cc82e..8502f5b41a 100644 --- a/src/Windows/Avalonia.Win32/Input/Imm32InputMethod.cs +++ b/src/Windows/Avalonia.Win32/Input/Imm32InputMethod.cs @@ -324,6 +324,11 @@ namespace Avalonia.Win32.Input if (IsActive) { Client.SetPreeditText(null); + + if (Client.SupportsSurroundingText && Client.SurroundingText.AnchorOffset != Client.SurroundingText.CursorOffset) + { + KeyPress(Key.Delete); + } } IsComposing = true; @@ -393,6 +398,19 @@ namespace Avalonia.Win32.Input return (int)(ptr.ToInt64() & 0xffffffff); } + private void KeyPress(Key key) + { + if (_parent?.Input != null) + { + _parent.Input(new RawKeyEventArgs(KeyboardDevice.Instance!, (ulong)DateTime.Now.Ticks, _parent.Owner, + RawKeyEventType.KeyDown, key, RawInputModifiers.None)); + + _parent.Input(new RawKeyEventArgs(KeyboardDevice.Instance!, (ulong)DateTime.Now.Ticks, _parent.Owner, + RawKeyEventType.KeyUp, key, RawInputModifiers.None)); + + } + } + ~Imm32InputMethod() { _caretManager.TryDestroy();