mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-22 19:19:26 +02:00
Qt: fixed crash and wrong events if key is changed in UTF8KeyPress.issue #26103
git-svn-id: trunk@44891 -
This commit is contained in:
parent
ec4d3bd225
commit
17a8339268
@ -2840,6 +2840,33 @@ var
|
|||||||
or (AQtKey = QtKey_Up) or (AQtKey = QtKey_Down));
|
or (AQtKey = QtKey_Up) or (AQtKey = QtKey_Down));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function SendChangedKey: boolean;
|
||||||
|
begin
|
||||||
|
if UTF8Char <> UTF8Text then
|
||||||
|
Text := UTF8ToUTF16(Utf8Char)
|
||||||
|
else
|
||||||
|
if Word(AChar) <> CharMsg.CharCode then
|
||||||
|
Text := Char(CharMsg.CharCode);
|
||||||
|
|
||||||
|
AKeyEvent := QKeyEvent_createExtendedKeyEvent(
|
||||||
|
QEvent_type(Event),
|
||||||
|
LCLKeyToQtKey(KeyMsg.CharCode),
|
||||||
|
Modifiers,
|
||||||
|
0,
|
||||||
|
KeyMsg.CharCode,
|
||||||
|
0,
|
||||||
|
@Text,
|
||||||
|
QKeyEvent_isAutoRepeat(QKeyEventH(Event)),
|
||||||
|
QKeyEvent_count(QKeyEventH(Event))
|
||||||
|
);
|
||||||
|
try
|
||||||
|
QObject_event(Sender, AKeyEvent);
|
||||||
|
finally
|
||||||
|
QKeyEvent_destroy(AKeyEvent);
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{$ifdef VerboseQt}
|
{$ifdef VerboseQt}
|
||||||
DebugLn('TQtWidget.SlotKey ', dbgsname(LCLObject));
|
DebugLn('TQtWidget.SlotKey ', dbgsname(LCLObject));
|
||||||
@ -3165,6 +3192,14 @@ begin
|
|||||||
if not CanSendLCLMessage or (Sender = nil) then
|
if not CanSendLCLMessage or (Sender = nil) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
if (UTF8Char <> UTF8Text) then
|
||||||
|
begin
|
||||||
|
// process changed key and exit.
|
||||||
|
// issue #26103
|
||||||
|
SendChangedKey;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
// create the CN_CHAR / CN_SYSCHAR message
|
// create the CN_CHAR / CN_SYSCHAR message
|
||||||
FillChar(CharMsg, SizeOf(CharMsg), 0);
|
FillChar(CharMsg, SizeOf(CharMsg), 0);
|
||||||
CharMsg.Msg := CN_CharMsg[IsSysKey];
|
CharMsg.Msg := CN_CharMsg[IsSysKey];
|
||||||
@ -3218,27 +3253,8 @@ begin
|
|||||||
(Word(AChar) <> CharMsg.CharCode)) then
|
(Word(AChar) <> CharMsg.CharCode)) then
|
||||||
begin
|
begin
|
||||||
// data was changed
|
// data was changed
|
||||||
if UTF8Char <> UTF8Text then
|
// moved to nested proc because of issue #26103
|
||||||
Text := UTF8ToUTF16(Utf8Char)
|
SendChangedKey;
|
||||||
else
|
|
||||||
if Word(AChar) <> CharMsg.CharCode then
|
|
||||||
Text := Char(CharMsg.CharCode);
|
|
||||||
AKeyEvent := QKeyEvent_createExtendedKeyEvent(
|
|
||||||
QEvent_type(Event),
|
|
||||||
LCLKeyToQtKey(KeyMsg.CharCode),
|
|
||||||
Modifiers,
|
|
||||||
0,
|
|
||||||
KeyMsg.CharCode,
|
|
||||||
0,
|
|
||||||
@Text,
|
|
||||||
QKeyEvent_isAutoRepeat(QKeyEventH(Event)),
|
|
||||||
QKeyEvent_count(QKeyEventH(Event))
|
|
||||||
);
|
|
||||||
try
|
|
||||||
QCoreApplication_sendEvent(Sender, AKeyEvent);
|
|
||||||
finally
|
|
||||||
QKeyEvent_destroy(AKeyEvent);
|
|
||||||
end;
|
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
Result := KeyMsg.CharCode in KeysToEat;
|
Result := KeyMsg.CharCode in KeysToEat;
|
||||||
|
Loading…
Reference in New Issue
Block a user