PDA

View Full Version : how to get key modifiers input.


MegaManZZ
11-12-2010, 02:44 PM
I'm making a character picker where you gotta click on 'iconTextButton' types to choose the handle to move.. I would like to have the freedom of using the 'modifier keys' (Shift, Cntrl) to specify whether , im adding, replacing, or removing selection.

I saw there is a '-dgc' flag, but am confuses as to how to use it. I read the documentation but it's a little beyond my realm..

maybe someone could help me out and show me a quick example of how to retrieve which modifier has been pressed.? that would be greatly appriciated

NaughtyNathan
11-12-2010, 07:03 PM
the -dgc flag is for drag/dropping and nothing to do with what you want or need. The simplest way to do this is to use the `getModifiers` command at the start of the function your button calls when pressed, then this function can determine whether to add, remove or replace based on the result returned from getModifiers.

Here's an example in MEL:
global proc doPress()
{
int $mod = `getModifiers`;
if (($mod/1)%2) print "SHIFT ";
if (($mod/2)%2) print "CAPS ";
if (($mod/4)%2) print "CTRL ";
if (($mod/8)%2) print "ALT ";
print " - Pushed!\n";
}

window;
columnLayout -adj 1;
button -l "Press Me" -c "doPress";
showWindow;
:nathaN

MegaManZZ
11-12-2010, 08:30 PM
Cool it works!.. thanks

Windows90
11-13-2010, 08:07 AM
Thanks Nathan! You are always so great!

CGTalk Moderation
11-13-2010, 08:07 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.