Cocoa: Fix #40985, enter the edit state in KeyDown()

This commit is contained in:
rich2014 2024-06-14 23:04:40 +08:00
parent 8692ed1de5
commit dcacf7aaac

View File

@ -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;