mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-26 15:33:46 +02:00
cocoa: Improves key state routine, fixes 64 bits compilation
git-svn-id: trunk@52534 -
This commit is contained in:
parent
1775e611f6
commit
c351a36c29
lcl/interfaces/cocoa
@ -54,6 +54,10 @@ type
|
||||
procedure setShouldAntialias(antialias: Boolean); message 'setShouldAntialias:';
|
||||
end;
|
||||
|
||||
NSEventFix = objccategory external (NSEvent)
|
||||
class function modifierFlags_: NSUInteger; message 'modifierFlags';
|
||||
end;
|
||||
|
||||
{// private since 10.5, doesn't seam to do anything in 10.10
|
||||
NSApplicationSetAppleMenu = objccategory external(NSApplication)
|
||||
procedure setAppleMenu(AMenu: NSMenu); message 'setAppleMenu:';
|
||||
|
@ -1892,7 +1892,9 @@ const
|
||||
var
|
||||
Modifiers: NSUInteger;
|
||||
begin
|
||||
Modifiers := NSApp.currentEvent.modifierFlags;
|
||||
// NSApp.currentEvent.modifierFlags doesn't work before events start coming,
|
||||
// see bug 29272 and http://lists.apple.com/archives/cocoa-dev/2010/Feb/msg00105.html
|
||||
Modifiers := NSEvent.modifierFlags_();
|
||||
case nVirtKey of
|
||||
VK_MENU,
|
||||
VK_LMENU:
|
||||
@ -1921,37 +1923,6 @@ begin
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
// NSApp.currentEvent.modifierFlags doesn't work before events start coming,
|
||||
// see bug 29272 and GetCurrentEventButtonState is supported in 64-bits
|
||||
case nVirtKey of
|
||||
VK_MENU:
|
||||
if (GetCurrentEventKeyModifiers() and optionKey) > 0 then
|
||||
// the ssAlt/VK_MENU is mapped to optionKey under MacOS
|
||||
Result := StateDown;
|
||||
VK_SHIFT:
|
||||
if (GetCurrentEventKeyModifiers() and shiftKey) > 0 then
|
||||
Result := StateDown;
|
||||
VK_CONTROL:
|
||||
if (GetCurrentEventKeyModifiers() and controlKey) > 0 then
|
||||
// the ssCtrl/VK_CONTROL is mapped to controlKey under MacOS
|
||||
Result := StateDown;
|
||||
VK_LWIN, VK_RWIN:
|
||||
// distinguish left and right
|
||||
if (GetCurrentEventKeyModifiers() and cmdKey) > 0 then
|
||||
// the ssMeta/VK_LWIN is mapped to cmdKey under MacOS
|
||||
Result := StateDown;
|
||||
VK_LBUTTON:
|
||||
if (GetCurrentEventButtonState() and $01) > 0 then Result := StateDown;
|
||||
VK_RBUTTON:
|
||||
if (GetCurrentEventButtonState() and $02) > 0 then Result := StateDown;
|
||||
VK_MBUTTON:
|
||||
if (GetCurrentEventButtonState() and $04) > 0 then Result := StateDown;
|
||||
VK_XBUTTON1:
|
||||
if (GetCurrentEventButtonState() and $08) > 0 then Result := StateDown;
|
||||
VK_XBUTTON2:
|
||||
if (GetCurrentEventButtonState() and $10) > 0 then Result := StateDown;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCocoaWidgetSet.SelectObject(ADC: HDC; GDIObj: HGDIOBJ): HGDIOBJ;
|
||||
|
Loading…
Reference in New Issue
Block a user