diff --git a/lcl/include/dbmemo.inc b/lcl/include/dbmemo.inc index fb20db4767..1073645087 100644 --- a/lcl/include/dbmemo.inc +++ b/lcl/include/dbmemo.inc @@ -150,6 +150,24 @@ begin if not FieldIsEditable(FDatalink.Field) or not FDataLink.Edit then Key := VK_UNKNOWN; end; +{$IFDEF DARWIN} +// the code for macOS here has been carefully considered +// and must be specially handled here. +// on macOS, because of the special key processing mechanism +// and the various possibilities combined with IME, +// we need to enter the editing state in KeyDown(). +// if we enter the edit state in KeyPress(), it is too late +// and will cause the Memo content to change, leading to the issue #40985 + VK_0..VK_9, + VK_A..VK_Z, + VK_NUMPAD0..VK_DIVIDE, + VK_OEM_1..VK_OEM_3, + VK_OEM_4..VK_OEM_8: + begin + if not FDatalink.Edit then + Key:= 0; + end; +{$ENDIF} end; end;