mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-15 14:29:31 +02:00
Qt: fixed bug with AltGr key handling under windows.We are using winapi directly as workaround for bug in Qt library. issue #23808
git-svn-id: trunk@41378 -
This commit is contained in:
parent
1abeb7d970
commit
467b293531
@ -192,6 +192,9 @@ type
|
||||
FLastMinimizeEvent: DWord; // track mainform minimize events -> TQtMainWindow.EventFilter
|
||||
FMinimizedByPager: Boolean; // track if app is minimized via desktop pager or by us.
|
||||
{$ENDIF}
|
||||
{$IFDEF MSWINDOWS}
|
||||
function GetWinKeyState(AKeyState: LongInt): SHORT;
|
||||
{$ENDIF}
|
||||
function CreateDefaultFont: HFONT; virtual;
|
||||
function GetDefaultAppFontName: WideString;
|
||||
function GetQtDefaultDC: HDC; virtual;
|
||||
|
@ -1346,6 +1346,13 @@ begin
|
||||
QWidget_setVisible(FDragImageList, NewVisible);
|
||||
end;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
function TQtWidgetSet.GetWinKeyState(AKeyState: LongInt): SHORT;
|
||||
begin
|
||||
Result := Windows.GetKeyState(AKeyState);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: CreateDefaultFont
|
||||
Params: none
|
||||
|
@ -2799,15 +2799,27 @@ begin
|
||||
if QEvent_type(Event) = QEventKeyRelease then
|
||||
LCLModifiers := LCLModifiers or KF_UP;
|
||||
|
||||
KeyMsg.KeyData := PtrInt((AKeyCode shl 16) or (LCLModifiers shl 16) or $0001);
|
||||
|
||||
{$ifdef windows}
|
||||
ACharCode := QKeyEvent_nativeVirtualKey(QKeyEventH(Event));
|
||||
KeyMsg.CharCode := ACharCode;
|
||||
// todo: VK to Win_VK for other os too
|
||||
//WriteLn(QKeyEvent_nativeVirtualKey(QKeyEventH(Event)));
|
||||
//WriteLn(QKeyEvent_nativeScanCode(QKeyEventH(Event)));
|
||||
ACharCode := QKeyEvent_nativeVirtualKey(QKeyEventH(Event));
|
||||
KeyMsg.CharCode := ACharCode;
|
||||
if (Modifiers = QtAltModifier or QtControlModifier) then
|
||||
begin
|
||||
if (QtWidgetSet.GetWinKeyState(VK_RMENU) < 0) and
|
||||
(QtWidgetSet.GetWinKeyState(VK_LCONTROL) < 0) then
|
||||
begin
|
||||
IsSysKey := False;
|
||||
LCLModifiers := 0;
|
||||
Modifiers := QtGroupSwitchModifier;
|
||||
|
||||
if QKeyEvent_isAutoRepeat(QKeyEventH(Event)) then
|
||||
LCLModifiers := LCLModifiers or KF_REPEAT;
|
||||
|
||||
if QEvent_type(Event) = QEventKeyRelease then
|
||||
LCLModifiers := LCLModifiers or KF_UP;
|
||||
end;
|
||||
end;
|
||||
{$endif}
|
||||
KeyMsg.KeyData := PtrInt((AKeyCode shl 16) or (LCLModifiers shl 16) or $0001);
|
||||
|
||||
// Loads the UTF-8 character associated with the keypress, if any
|
||||
QKeyEvent_text(QKeyEventH(Event), @Text);
|
||||
|
@ -2975,6 +2975,16 @@ const
|
||||
begin
|
||||
Result := 0;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
if (nVirtKey = VK_CONTROL) or (nVirtKey = VK_MENU) or
|
||||
(nVirtKey = VK_LCONTROL) or (nVirtKey = VK_LMENU) then
|
||||
begin
|
||||
if (GetWinKeyState(VK_RMENU) < 0) and
|
||||
(GetWinKeyState(VK_LCONTROL) < 0) then
|
||||
exit;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
case nVirtKey of
|
||||
VK_LSHIFT: nVirtKey := VK_SHIFT;
|
||||
VK_LCONTROL: nVirtKey := VK_CONTROL;
|
||||
@ -2982,7 +2992,6 @@ begin
|
||||
end;
|
||||
|
||||
// where to track toggle state?
|
||||
|
||||
case nVirtKey of
|
||||
VK_LBUTTON:
|
||||
if (QApplication_mouseButtons and QtLeftButton) > 0 then
|
||||
@ -3014,7 +3023,7 @@ begin
|
||||
VK_LCL_CAPSLOCK, VK_NUMLOCK:
|
||||
begin
|
||||
{$IFDEF MSWINDOWS}
|
||||
Result := Windows.GetKeyState(nVirtKey);
|
||||
Result := GetWinKeyState(nVirtKey);
|
||||
{$ELSE}
|
||||
{$IFDEF HASX11}
|
||||
if GetKeyLockState(nVirtKey) then
|
||||
|
Loading…
Reference in New Issue
Block a user