如何使用OSM上的FireMonkey获取当前的修改器状态? [英] How to get current modifier states with FireMonkey on OSX?
本文介绍了如何使用OSM上的FireMonkey获取当前的修改器状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对于Windows,我通常使用 Delphi ,我通常使用以下代码:
With Delphi for Windows, I usually use this code:
function isCtrlDown : Boolean;
var
ksCurrent : TKeyboardState;
begin
GetKeyboardState(ksCurrent);
Result := ((ksCurrent[VK_CONTROL] and 128) <> 0);
end;
如何在Mac OSX上使用FireMonkey实现?
我发现这个,但是我不知道如何使用FireMonkey / Delphi(使用...)来管理它:
I have found this, but I don't know how to manage it with FireMonkey/Delphi (which uses, ...):
void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey)
{
UInt32 currentModifiers = GetCurrentKeyModifiers();
shiftKey = currentModifiers & ::shiftKey;
ctrlKey = currentModifiers & ::controlKey;
altKey = currentModifiers & ::optionKey;
metaKey = currentModifiers & ::cmdKey;
}
我还在调查...
现在,我找到这个单位与重要事件东西...
单位Macapi.AppKit;
I'm still investigating...
For now, I have find this unit with key events stuff...
unit Macapi.AppKit;
推荐答案
根据这个答案你可以试试这个:
Based on this answer you could try this:
function isCtrlDown : Boolean;
begin
Result := NSControlKeyMask and TNSEvent.OCClass.modifierFlags = NSControlKeyMask;
end;
这篇关于如何使用OSM上的FireMonkey获取当前的修改器状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文