mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 16:39:15 +02:00
qt: improve GetKeyState - make it more windows compatible
git-svn-id: trunk@14267 -
This commit is contained in:
parent
54208be697
commit
3faf42a722
@ -114,6 +114,8 @@ begin
|
|||||||
TEventFilterMethod(Method) := @EventFilter;
|
TEventFilterMethod(Method) := @EventFilter;
|
||||||
QObject_hook_hook_events(FHook, Method);
|
QObject_hook_hook_events(FHook, Method);
|
||||||
|
|
||||||
|
// install focus change slot
|
||||||
|
|
||||||
ScreenDC := GetDC(0);
|
ScreenDC := GetDC(0);
|
||||||
try
|
try
|
||||||
ScreenInfo.PixelsPerInchX := GetDeviceCaps(ScreenDC, LOGPIXELSX);
|
ScreenInfo.PixelsPerInchX := GetDeviceCaps(ScreenDC, LOGPIXELSX);
|
||||||
|
@ -2076,6 +2076,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TQtWidgetSet.GetKeyState(nVirtKey: Integer): Smallint;
|
function TQtWidgetSet.GetKeyState(nVirtKey: Integer): Smallint;
|
||||||
|
const
|
||||||
|
StateDown = SmallInt($FF80); // rather strange interpretation of "high-order bit is 1", but windows returns it
|
||||||
|
StateToggled = SmallInt($0001);
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
|
|
||||||
@ -2085,25 +2088,27 @@ begin
|
|||||||
VK_LMENU: nVirtKey := VK_MENU;
|
VK_LMENU: nVirtKey := VK_MENU;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// where to track toggle state?
|
||||||
|
|
||||||
case nVirtKey of
|
case nVirtKey of
|
||||||
VK_MENU:
|
|
||||||
if (QApplication_keyboardModifiers and QtMetaModifier) > 0 then
|
|
||||||
Result:=-1;
|
|
||||||
VK_SHIFT:
|
|
||||||
if (QApplication_keyboardModifiers and QtShiftModifier) > 0 then
|
|
||||||
Result:=-1;
|
|
||||||
VK_CONTROL:
|
|
||||||
if (QApplication_keyboardModifiers and QtControlModifier) > 0 then
|
|
||||||
Result:=-1;
|
|
||||||
VK_LBUTTON:
|
VK_LBUTTON:
|
||||||
if (QApplication_mouseButtons and QtLeftButton) > 0 then
|
if (QApplication_mouseButtons and QtLeftButton) > 0 then
|
||||||
Result := -1;
|
Result := Result or StateDown;
|
||||||
VK_RBUTTON:
|
VK_RBUTTON:
|
||||||
if (QApplication_mouseButtons and QtRightButton) > 0 then
|
if (QApplication_mouseButtons and QtRightButton) > 0 then
|
||||||
Result := -1;
|
Result := Result or StateDown;
|
||||||
VK_MBUTTON:
|
VK_MBUTTON:
|
||||||
if (QApplication_mouseButtons and QtMidButton) > 0 then
|
if (QApplication_mouseButtons and QtMidButton) > 0 then
|
||||||
Result := -1;
|
Result := Result or StateDown;
|
||||||
|
VK_MENU:
|
||||||
|
if (QApplication_keyboardModifiers and QtMetaModifier) > 0 then
|
||||||
|
Result := Result or StateDown;
|
||||||
|
VK_SHIFT:
|
||||||
|
if (QApplication_keyboardModifiers and QtShiftModifier) > 0 then
|
||||||
|
Result := Result or StateDown;
|
||||||
|
VK_CONTROL:
|
||||||
|
if (QApplication_keyboardModifiers and QtControlModifier) > 0 then
|
||||||
|
Result := Result or StateDown;
|
||||||
else
|
else
|
||||||
DebugLn('TQtWidgetSet.GetKeyState TODO ', DbgSVKCode(Word(nVirtkey)));
|
DebugLn('TQtWidgetSet.GetKeyState TODO ', DbgSVKCode(Word(nVirtkey)));
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user