mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 15:59:13 +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
|
FLastMinimizeEvent: DWord; // track mainform minimize events -> TQtMainWindow.EventFilter
|
||||||
FMinimizedByPager: Boolean; // track if app is minimized via desktop pager or by us.
|
FMinimizedByPager: Boolean; // track if app is minimized via desktop pager or by us.
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
{$IFDEF MSWINDOWS}
|
||||||
|
function GetWinKeyState(AKeyState: LongInt): SHORT;
|
||||||
|
{$ENDIF}
|
||||||
function CreateDefaultFont: HFONT; virtual;
|
function CreateDefaultFont: HFONT; virtual;
|
||||||
function GetDefaultAppFontName: WideString;
|
function GetDefaultAppFontName: WideString;
|
||||||
function GetQtDefaultDC: HDC; virtual;
|
function GetQtDefaultDC: HDC; virtual;
|
||||||
|
@ -1346,6 +1346,13 @@ begin
|
|||||||
QWidget_setVisible(FDragImageList, NewVisible);
|
QWidget_setVisible(FDragImageList, NewVisible);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IFDEF MSWINDOWS}
|
||||||
|
function TQtWidgetSet.GetWinKeyState(AKeyState: LongInt): SHORT;
|
||||||
|
begin
|
||||||
|
Result := Windows.GetKeyState(AKeyState);
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Function: CreateDefaultFont
|
Function: CreateDefaultFont
|
||||||
Params: none
|
Params: none
|
||||||
|
@ -2799,15 +2799,27 @@ begin
|
|||||||
if QEvent_type(Event) = QEventKeyRelease then
|
if QEvent_type(Event) = QEventKeyRelease then
|
||||||
LCLModifiers := LCLModifiers or KF_UP;
|
LCLModifiers := LCLModifiers or KF_UP;
|
||||||
|
|
||||||
KeyMsg.KeyData := PtrInt((AKeyCode shl 16) or (LCLModifiers shl 16) or $0001);
|
|
||||||
|
|
||||||
{$ifdef windows}
|
{$ifdef windows}
|
||||||
ACharCode := QKeyEvent_nativeVirtualKey(QKeyEventH(Event));
|
ACharCode := QKeyEvent_nativeVirtualKey(QKeyEventH(Event));
|
||||||
KeyMsg.CharCode := ACharCode;
|
KeyMsg.CharCode := ACharCode;
|
||||||
// todo: VK to Win_VK for other os too
|
if (Modifiers = QtAltModifier or QtControlModifier) then
|
||||||
//WriteLn(QKeyEvent_nativeVirtualKey(QKeyEventH(Event)));
|
begin
|
||||||
//WriteLn(QKeyEvent_nativeScanCode(QKeyEventH(Event)));
|
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}
|
{$endif}
|
||||||
|
KeyMsg.KeyData := PtrInt((AKeyCode shl 16) or (LCLModifiers shl 16) or $0001);
|
||||||
|
|
||||||
// Loads the UTF-8 character associated with the keypress, if any
|
// Loads the UTF-8 character associated with the keypress, if any
|
||||||
QKeyEvent_text(QKeyEventH(Event), @Text);
|
QKeyEvent_text(QKeyEventH(Event), @Text);
|
||||||
|
@ -2975,6 +2975,16 @@ const
|
|||||||
begin
|
begin
|
||||||
Result := 0;
|
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
|
case nVirtKey of
|
||||||
VK_LSHIFT: nVirtKey := VK_SHIFT;
|
VK_LSHIFT: nVirtKey := VK_SHIFT;
|
||||||
VK_LCONTROL: nVirtKey := VK_CONTROL;
|
VK_LCONTROL: nVirtKey := VK_CONTROL;
|
||||||
@ -2982,7 +2992,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// where to track toggle state?
|
// where to track toggle state?
|
||||||
|
|
||||||
case nVirtKey of
|
case nVirtKey of
|
||||||
VK_LBUTTON:
|
VK_LBUTTON:
|
||||||
if (QApplication_mouseButtons and QtLeftButton) > 0 then
|
if (QApplication_mouseButtons and QtLeftButton) > 0 then
|
||||||
@ -3014,7 +3023,7 @@ begin
|
|||||||
VK_LCL_CAPSLOCK, VK_NUMLOCK:
|
VK_LCL_CAPSLOCK, VK_NUMLOCK:
|
||||||
begin
|
begin
|
||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
Result := Windows.GetKeyState(nVirtKey);
|
Result := GetWinKeyState(nVirtKey);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
{$IFDEF HASX11}
|
{$IFDEF HASX11}
|
||||||
if GetKeyLockState(nVirtKey) then
|
if GetKeyLockState(nVirtKey) then
|
||||||
|
Loading…
Reference in New Issue
Block a user