LCL-CustomDrawn: Improve TEdit key press events. Issue #40221, patch by Alexey Torgashin.

This commit is contained in:
Juha 2023-04-21 12:45:31 +03:00
parent 027553282a
commit 9e69dd9798

View File

@ -288,7 +288,7 @@ end;
procedure CallbackKeyChar(AWindowHandle: TCDForm; AKeyData: Word; AChar: TUTF8Char); procedure CallbackKeyChar(AWindowHandle: TCDForm; AKeyData: Word; AChar: TUTF8Char);
var var
lTarget: TWinControl; lTarget: TWinControl;
lCharCode: Word = 0; lCharCode: Word;
begin begin
lTarget := AWindowHandle.GetFocusedControl(); lTarget := AWindowHandle.GetFocusedControl();
{$ifdef VerboseCDEvents} {$ifdef VerboseCDEvents}
@ -296,17 +296,20 @@ begin
{$endif} {$endif}
if lTarget = nil then Exit; // Fixes a crash if lTarget = nil then Exit; // Fixes a crash
if Length(AChar) = 1 then lCharCode := Word(AChar[1]); if Length(AChar) = 1 then
lCharCode := Byte(AChar[1])
else
lCharCode:=0;
// if lCharCode <> 0 then LCLSendCharEvent(lTarget, lCharCode, AKeyData, True, False, True); if AChar<>'' then LCLSendUTF8KeyPress(lTarget, AChar, False);
LCLSendUTF8KeyPress(lTarget, AChar, 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 this is a interface control, send the message to the main LCL control too
if IsIntfControl(lTarget) then if IsIntfControl(lTarget) then
begin begin
lTarget := lTarget.Parent; lTarget := lTarget.Parent;
// if lCharCode <> 0 then LCLSendCharEvent(lTarget, lCharCode, AKeyData, True, False, True); if AChar<>'' then LCLSendUTF8KeyPress(lTarget, AChar, False);
LCLSendUTF8KeyPress(lTarget, AChar, False); if lCharCode <> 0 then LCLSendCharEvent(lTarget, lCharCode, AKeyData, True, False, True);
end; end;
end; end;