Browse Source

Merge pull request #11809 from Gillibald/fixes/windowsIME

[Windows] Make sure the InputMethod deletes current selection before preedit is set
pull/11972/head
Max Katz 3 years ago
committed by GitHub
parent
commit
28e9b3a49d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      src/Windows/Avalonia.Win32/Input/Imm32InputMethod.cs

18
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();

Loading…
Cancel
Save