Last active
January 16, 2020 12:06
-
-
Save shspage/5e044ea189d0097f96e08444e370b093 to your computer and use it in GitHub Desktop.
[Illustrator SDK] シフト+クリックで何かする。 // もっと今時の簡単な書き方あるのかもしれないけど、とりあえず動作する → SDKの機能で簡単に書けた
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @peprintenpa さんに教えていただいた、SDKの機能を使う方法。 | |
// ref: https://twitter.com/peprintenpa/status/1217626021630857216 | |
AIErr MyTool::ToolMouseDown( AIToolMessage* message ) | |
{ | |
if(message->event->modifiers & aiEventModifiers_shiftKey){ | |
sAIUser->MessageAlert(ai::UnicodeString("shift is down")); | |
} | |
// ... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// キー状態の取得にSDKの機能を使わない場合 | |
// ... | |
#ifdef MAC_ENV | |
#include <Carbon/Carbon.h> // need to add Carbon.Framework to Build Phases/Link Binary With Libraries | |
#endif | |
// ... | |
// ---- | |
static bool isShiftKeyDown(){ | |
#ifdef MAC_ENV | |
// ref: https://stackoverflow.com/questions/11466294/getting-keyboard-state-using-getkeys-function | |
uint16_t vKey = kVK_Shift; | |
uint8_t index = vKey / 32; | |
uint8_t shift = vKey % 32; | |
KeyMap keystate; | |
GetKeys(keystate); | |
return keystate[index].bigEndianValue & (1 << shift); | |
#else | |
return GetKeyState(VK_SHIFT) & 0x80; | |
#endif | |
} | |
// ---- | |
AIErr MyTool::ToolMouseDown( AIToolMessage* message ) | |
{ | |
if(isShiftKeyDown()){ | |
sAIUser->MessageAlert(ai::UnicodeString("shift is down")); | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment