PDA

View Full Version : XSI's Sticky Keys for Maya!


Iconoklast
01-14-2005, 07:00 PM
Ok, this is a bit primitive and needs implementing with tools, but I've managed to make a nice clean replica of XSI's very handy sticky keys. If you're unfamiliar with them, basically the way they work is, if you have say, the scale tool selected, and you press and hold the move tool, do your moving, and then release the move tool key, it will switch you back to scale. If you just tap the move tool, instead of holding it down, it will switch to the move tool permanently.

Anyway, the code isn't very elegant, and what I have here is just a testing purpose (only works for the move tool), but I thought I'd paste it for others to have a mess with aswell.

Here how it setup:
Go to the hotkey editor and create 'New'. Call this 'StickyMove' and paste the following:
global float $start;
global string $gMove;
global string $tool;
global string $newTool;
float $start = `timerX`;
$tool = `currentCtx`;
setToolTo $gMove;
$newTool = `currentCtx`;

hit 'accept'. Create another one ('New') and call this StickyMoveRelease, and put this in the command area:
global float $start;
global string $tool;
global string $newTool;
float $time = `timerX -st $start`;
print $time;
if ($time > 0.1)
setToolTo $tool;
else
setToolTo $newTool;

Now just bind StickyMove to a key, and StickyMoveRelease to the same key but make sure the 'release' radio button is checked.
Then, create a cube, grab the scale tool, do some scaling, then hit the hotkey, move it around a bit, then release and it will switch you back to scale. Or, tap the hotkey and it will switch you to move permanently

It's obviously not as well implemented as XSI's sticky keys, since it works on all keys there, and here you have to make ones for individual keys, but I think sticky keys are really handy and pleasant to use and thought I'd figure out a way to have them in maya.

goleafsgo
01-14-2005, 08:01 PM
Does this interfere with the fact that holding down the "w" key, for instance, and then using RMB brings up move tool options?
If you are in the scale tool, and then hold down "w" and, using RMB, switch the move tool to Local and then let go does it go back to the scale tool?

Iconoklast
01-14-2005, 08:25 PM
I modified the 'w' marking menu to bring up with the middle mouse button, so it doesn't interfere. To have it work with the 'w' marking menu, do this for StickyMove:

global float $start;
global string $gMove;
global string $tool;
global string $newTool;
float $start = `timerX`;
$tool = `currentCtx`;
buildTranslateMM;
$newTool = `currentCtx`;

And do this for StickyMoveRelease:

global float $start;
global string $tool;
global string $newTool;
float $time = `timerX -st $start`;
print $time;
if ($time > 0.1)
setToolTo $tool;
else
setToolTo $newTool;
MarkingMenuPopDown;

That should make is so when you have the hotkey held down, it will allow you to MMB click and bring up the menu, and LMB will allow you to mvoe the object around. Releasing will bring you back to your previous tool. If you tap the hotkey, it will just switch you to the move tool.

]-UnderTOW-[
01-14-2005, 09:04 PM
Nice idea :) I did like that feature from XSI

roger3d
01-15-2005, 08:54 AM
:thumbsup: Thanks for sharing this great script!

Iconoklast
01-15-2005, 12:56 PM
I created a script called stickyKeys.mel. It just basically cleans it up so you don't need to put all those commands in the command box. All you need to do now is have:

stickKeys 1 <tool>;

in the press hotkey, and:

stickyKeys 0 <tool>;

in the release hotkey.

If you want to have the marking menus, for w, r, e. Then, for example, 'w' would be

stickyKeys 1 BuildTranslateMM;

for press, and:

stickyKeys 0 BuildTranslateMM;

for release.

vaniljus
01-15-2005, 02:42 PM
I love it, thanks for the script.

Iconoklast
02-08-2005, 04:32 PM
I've updated the script so that it now works on commands, aswell. Previously, it just worked on tools, (move, select, scale, whatever returns when 'currentCtx' is queried).

For example, try this:

create a new command in the hotkey editor, and in the press command put:

stickyKeys 1 "snapMode -grid (!`snapMode -q -grid`)";

and in the release command put:

stickyKeys 0 "snapMode -grid (!`snapMode -q -grid`)";

bind this to the 'x' key. (make sure the release is hotkey'ed).

Now, tapping the x key will turn on and off grid snapping. Holding it down will work as normal. With the addition of remembering your current tool. For example, have the select tool enabled. Select an object, then hold down 'x' and while still holding, enable the move tool. Move the object around. Now release. It turns off grid snapping, and also switches you back to the select tool.

On that note, the command to have it work on just tools is changed slightly.

So to have it work on the move tool, you must do
stickyKeys 1 "setToolTo $gMove"; // for press
and
stickyKeys 0 "setToolTo $gMove"; // for release.

I haven't thoroughly tested the command thing on anything other than the snapping, but it should work on pretty much anything else.

morimitsu
02-09-2005, 04:41 PM
thanks for sharing it!

eatbug
02-09-2005, 05:25 PM
I will have a try :0, thank you :)

CGTalk Moderation
02-09-2006, 06:00 PM
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.