Default constants
-
When listing
Object.constants
I find these constants in the results:MK_ALT MK_COMMAND MK_CONTROL MK_LBUTTON MK_MBUTTON MK_RBUTTON MK_SHIFT MK_ALT
But I see no reference in the manual to them. Are they added by a plugin? How can I find out what is SU constants and what is plugin constants?
-
@thomthom said:
... I see no reference in the manual to them. Are they added by a plugin? How can I find out what is SU constants and what is plugin constants?
I can't find the reference now.. but I 'think' these were added by Google when they fixed the onMButtonDown and onMButtonUp callbacks (Tool Class) in SU 7.0 ... but the constants I 'think' are meant to be used with Tool.onKeyDown and Tool.onKeyUp.
ie:
def onKeyDown(key, repeat, flags, view) %(#F0F0F0)[__]if key = MK_LBUTTON %(#F0F0F0)[____]if flags = MK_ALT %(#F0F0F0)[______]# do something special %(#F0F0F0)[____]else %(#F0F0F0)[______]# do normal pick %(#F0F0F0)[____]end %(#F0F0F0)[__]end end
My brain 'thinks' I read it in a non-official mention, perhaps an offhand remark in the forums by a Google SUTM.
-
@thomthom said:
How can I find out what is SU constants and what is plugin constants?
It's easy.
(1) Make a COPY of the Sketchup folder and subfolders (EXCEPT Plugins)
Call it "Google Sketchup 7 Nude" (or similar)
(2) Make an empty 'Plugins' folder, under the "nude" copy.
(3) Either create an NEW user account (or use your Administrator account)
(4) Switch to the other account (Log off if you wish, or not.)
(5) On the other account, make a shortcut to to the "Nude" Sketchup.
Don't run the "Nude" Sketchup on your 'normal' account as it will change the settings in your 'normal' Registry Hive!!!
(6) Run 'Nude' Sketchup on the New (or other account). Check Prference Settings for those things in the 'Tools' folder so that they are at minimum (probably DC only.)Now you have a way to check what comes with the base API, by switching users and running the 'Nude version.'
-
I made a list of SU and some Ruby constants here:
Not sure about the MK_ constants. For keys, I always guessed VK_ (virtual key?) were to be used.
There are MF_ constants dealing with menu items, so maybe they are menu-related, but I'm not sure what they'd be used for. Can you determine if a menu item is clicked while the Ctrl key is down, for example?
-
No - no way to get Ctrl/Shift/Alt for menu items.
I think the MF is used for key events.
For modifiers on mouse down/up events I found these to be the best choice:
* ALT_MODIFIER_MASK
* ALT_MODIFIER_KEY* CONSTRAIN_MODIFIER_MASK * CONSTRAIN_MODIFIER_KEY * COPY_MODIFIER_MASK * COPY_MODIFIER_KEY
Though, it seems that to check the flags for the key presses the *_MASK is the ones you should use. On OSX they appear to be all the same, but on PC the _MASK and _KEY is different. And the values returned differs from PC and OSX.
Wish the manual would clarify this instead of just throwing them out there...
-
from Windows SDK, WinUser.h, line 2373...
[language=C]:
*` %(#008B8B)[/- Key State Masks for Mouse Messages
/
#define MK_LBUTTON 0x0001
#define MK_RBUTTON 0x0002
#define MK_SHIFT 0x0004
#define MK_CONTROL 0x0008
#define MK_MBUTTON 0x0010
#if(_WIN32_WINNT >= 0x0500)
#define MK_XBUTTON1 0x0020
#define MK_XBUTTON2 0x0040
#endif / _WIN32_WINNT >= 0x0500 /]`*
- Key State Masks for Mouse Messages
Advertisement