Modification of procedure CallbackKeyChar
By 'lagprogramming' on forum.
The following patch modifies procedure CallbackKeyChar(AWindowHandle: TCDForm; AKeyData: Word; AChar: TUTF8Char);
It replaces the lines that look like
if AChar<>'' then LCLSendUTF8KeyPress(lTarget, AChar, False);
with
if AChar<>'' then lTarget.IntfUTF8KeyPress(AChar, 1, False);
If the patch is accepted the customdrawn bug will be fixed without modifying the function LCLSendUTF8KeyPress in lclmessageglue.pas. Also, none of the routines in the official source code of Lazarus will use the function LCLSendUTF8KeyPress. This means that you can close the Lazarus issues #40211 (closed) and #40224 (closed). Everybody should be happy, except for an eventual fpgui lcl implentation developer.
diff --git a/lcl/interfaces/customdrawn/customdrawnprivate.pas b/lcl/interfaces/customdrawn/customdrawnprivate.pas
index 7a95139583..755d7aa8f5 100644
--- a/lcl/interfaces/customdrawn/customdrawnprivate.pas
+++ b/lcl/interfaces/customdrawn/customdrawnprivate.pas
@@ -301,14 +301,16 @@ begin
else
lCharCode:=0;
- if AChar<>'' then LCLSendUTF8KeyPress(lTarget, AChar, False);
+ // Do not use LCLSendUTF8KeyPress! See Lazarus issues: #40211 and #40224
+ if AChar<>'' then lTarget.IntfUTF8KeyPress(AChar, 1, False);
if lCharCode <> 0 then LCLSendCharEvent(lTarget, lCharCode, AKeyData, True, False, True);
// If this is a interface control, send the message to the main LCL control too
if IsIntfControl(lTarget) then
begin
lTarget := lTarget.Parent;
- if AChar<>'' then LCLSendUTF8KeyPress(lTarget, AChar, False);
+ // Do not use LCLSendUTF8KeyPress! See Lazarus issues: #40211 and #40224
+ if AChar<>'' then lTarget.IntfUTF8KeyPress(AChar, 1, False);
if lCharCode <> 0 then LCLSendCharEvent(lTarget, lCharCode, AKeyData, True, False, True);
end;
end;
Edited by Alexey Torgashin