Skip to content

Commit 8f7e055

Browse files
authored
Set _ignoreWmChar when IME sends a ImeProcessed key to prevent input via WM_CHAR (#12942)
1 parent ae765e6 commit 8f7e055

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -775,12 +775,19 @@ protected virtual unsafe IntPtr AppWndProc(IntPtr hWnd, uint msg, IntPtr wParam,
775775

776776
if (message == WindowsMessage.WM_KEYDOWN)
777777
{
778-
// Handling a WM_KEYDOWN message should cause the subsequent WM_CHAR message to
779-
// be ignored. This should be safe to do as WM_CHAR should only be produced in
780-
// response to the call to TranslateMessage/DispatchMessage after a WM_KEYDOWN
781-
// is handled.
782-
_ignoreWmChar = e.Handled;
783-
}
778+
if(e is RawKeyEventArgs args && args.Key == Key.ImeProcessed)
779+
{
780+
_ignoreWmChar = true;
781+
}
782+
else
783+
{
784+
// Handling a WM_KEYDOWN message should cause the subsequent WM_CHAR message to
785+
// be ignored. This should be safe to do as WM_CHAR should only be produced in
786+
// response to the call to TranslateMessage/DispatchMessage after a WM_KEYDOWN
787+
// is handled.
788+
_ignoreWmChar = e.Handled;
789+
}
790+
}
784791

785792
if (s_intermediatePointsPooledList.Count > 0)
786793
{

0 commit comments

Comments
 (0)