mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 21:41:01 +02:00
QT: fix not triggering OnKeyDown/On(Utf8)KeyPress when typing diacritics using
"dead keys" in several controls. Issue #0026115 git-svn-id: trunk@44930 -
This commit is contained in:
parent
6a9ea0f2ff
commit
00158cb54c
@ -189,6 +189,7 @@ type
|
|||||||
function slotDropFiles(Sender: QObjectH; Event: QEventH): Boolean;
|
function slotDropFiles(Sender: QObjectH; Event: QEventH): Boolean;
|
||||||
function SlotHover(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
function SlotHover(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
||||||
function SlotKey(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
function SlotKey(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
||||||
|
function SlotInputMethod(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
||||||
function SlotMouse(Sender: QObjectH; Event: QEventH): Boolean; virtual; cdecl;
|
function SlotMouse(Sender: QObjectH; Event: QEventH): Boolean; virtual; cdecl;
|
||||||
procedure SlotNCMouse(Sender: QObjectH; Event: QEventH); cdecl;
|
procedure SlotNCMouse(Sender: QObjectH; Event: QEventH); cdecl;
|
||||||
function SlotMouseEnter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
function SlotMouseEnter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
||||||
@ -2480,6 +2481,13 @@ begin
|
|||||||
((LCLObject <> nil) and (LCLObject is TCustomControl));
|
((LCLObject <> nil) and (LCLObject is TCustomControl));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
//Dead keys (used to compose chars like "ó" by pressing 'o) do not trigger EventKeyPress
|
||||||
|
//and therefore no KeyDown,Utf8KeyPress,KeyPress
|
||||||
|
QEventInputMethod:
|
||||||
|
begin
|
||||||
|
Result := SlotInputMethod(Sender, Event);
|
||||||
|
end;
|
||||||
|
|
||||||
QEventMouseButtonPress,
|
QEventMouseButtonPress,
|
||||||
QEventMouseButtonRelease,
|
QEventMouseButtonRelease,
|
||||||
QEventMouseButtonDblClick: Result := SlotMouse(Sender, Event);
|
QEventMouseButtonDblClick: Result := SlotMouse(Sender, Event);
|
||||||
@ -3275,6 +3283,41 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TQtWidget.SlotInputMethod(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
||||||
|
var
|
||||||
|
InputEvent: QInputMethodEventH;
|
||||||
|
WStr: WideString;
|
||||||
|
UnicodeChar: Cardinal;
|
||||||
|
UnicodeOutLen: integer;
|
||||||
|
KeyEvent: QKeyEventH;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
if not (QEvent_type(Event) = QEventInputMethod) then Exit;
|
||||||
|
{$ifdef VerboseQt}
|
||||||
|
DebugLn('TQtWidget.SlotInputMethod ', dbgsname(LCLObject));
|
||||||
|
{$endif}
|
||||||
|
InputEvent := QInputMethodEventH(Event);
|
||||||
|
QInputMethodEvent_commitString(InputEvent, @WStr);
|
||||||
|
UnicodeChar := UTF8CharacterToUnicode(PChar(WStr), UnicodeOutLen);
|
||||||
|
{$IFDEF VerboseQtKeys}
|
||||||
|
writeln('> TQtWidget.SlotInputMethod ',dbgsname(LCLObject),' event=QEventInputMethod:');
|
||||||
|
writeln(' commmitString ',WStr,' len ',length(WStr),' UnicodeChar ',UnicodeChar,
|
||||||
|
' UnicodeLen ',UnicodeOutLen);
|
||||||
|
writeln(' sending QEventKeyPress');
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
KeyEvent := QKeyEvent_create(QEventKeyPress, PtrInt(UnicodeChar), QApplication_keyboardModifiers, @WStr, False, 1);
|
||||||
|
try
|
||||||
|
// do not send it to queue, just pass it to SlotKey
|
||||||
|
Result := SlotKey(Sender, KeyEvent);
|
||||||
|
finally
|
||||||
|
QKeyEvent_destroy(KeyEvent);
|
||||||
|
end;
|
||||||
|
{$IFDEF VerboseQtKeys}
|
||||||
|
writeln('< TQtWidget.SlotInputMethod End: ',dbgsname(LCLObject),' event=QEventInputMethod, sent QEventKeyPress');
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Function: TQtWidget.SlotMouse
|
Function: TQtWidget.SlotMouse
|
||||||
Params: None
|
Params: None
|
||||||
@ -15712,12 +15755,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TQtCustomControl.EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
function TQtCustomControl.EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
||||||
var
|
|
||||||
InputEvent: QInputMethodEventH;
|
|
||||||
WStr: WideString;
|
|
||||||
UnicodeOutLen: Integer;
|
|
||||||
UnicodeChar: Cardinal;
|
|
||||||
KeyEvent: QKeyEventH;
|
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
QEvent_accept(Event);
|
QEvent_accept(Event);
|
||||||
@ -15734,28 +15771,6 @@ begin
|
|||||||
(ClassType = TQtCustomControl) then
|
(ClassType = TQtCustomControl) then
|
||||||
Result := False
|
Result := False
|
||||||
else
|
else
|
||||||
if QEvent_type(Event) = QEventInputMethod then
|
|
||||||
begin
|
|
||||||
InputEvent := QInputMethodEventH(Event);
|
|
||||||
QInputMethodEvent_commitString(InputEvent, @WStr);
|
|
||||||
UnicodeChar := UTF8CharacterToUnicode(PChar(WStr), UnicodeOutLen);
|
|
||||||
{$IFDEF VerboseQtKeys}
|
|
||||||
writeln('> TQtCustomControl.EventFilter event=QEventInputMethod');
|
|
||||||
writeln(' commmitString ',WStr,' len ',length(WStr),' UnicodeChar ',UnicodeChar,
|
|
||||||
' UnicodeLen ',UnicodeOutLen);
|
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
KeyEvent := QKeyEvent_create(QEventKeyPress, PtrInt(UnicodeChar), QApplication_keyboardModifiers, @WStr, False, 1);
|
|
||||||
try
|
|
||||||
// do not send it to queue, just pass it to SlotKey
|
|
||||||
Result := SlotKey(Sender, KeyEvent);
|
|
||||||
finally
|
|
||||||
QKeyEvent_destroy(KeyEvent);
|
|
||||||
end;
|
|
||||||
{$IFDEF VerboseQtKeys}
|
|
||||||
writeln('< TQtCustomControl.EventFilter event=QEventInputMethod sent QEventKeyPress');
|
|
||||||
{$ENDIF}
|
|
||||||
end else
|
|
||||||
if QEvent_type(Event) = QEventWheel then
|
if QEvent_type(Event) = QEventWheel then
|
||||||
begin
|
begin
|
||||||
if not getEnabled then
|
if not getEnabled then
|
||||||
|
Loading…
Reference in New Issue
Block a user