qt: improve GetKeyState - make it more windows compatible

git-svn-id: trunk@14267 -
This commit is contained in:
paul 2008-02-27 06:07:35 +00:00
parent 54208be697
commit 3faf42a722
2 changed files with 20 additions and 13 deletions

View File

@ -114,6 +114,8 @@ begin
TEventFilterMethod(Method) := @EventFilter;
QObject_hook_hook_events(FHook, Method);
// install focus change slot
ScreenDC := GetDC(0);
try
ScreenInfo.PixelsPerInchX := GetDeviceCaps(ScreenDC, LOGPIXELSX);

View File

@ -2076,6 +2076,9 @@ begin
end;
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
Result := 0;
@ -2085,25 +2088,27 @@ begin
VK_LMENU: nVirtKey := VK_MENU;
end;
// where to track toggle state?
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:
if (QApplication_mouseButtons and QtLeftButton) > 0 then
Result := -1;
Result := Result or StateDown;
VK_RBUTTON:
if (QApplication_mouseButtons and QtRightButton) > 0 then
Result := -1;
Result := Result or StateDown;
VK_MBUTTON:
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
DebugLn('TQtWidgetSet.GetKeyState TODO ', DbgSVKCode(Word(nVirtkey)));
end;