user marking menu hot keys

david | mel script | Thursday, March 13th, 2008

In maya I have a lot of marking menus, several of which are "user marking menus" that I created using the marking menu editor, while others are created dynamically by mel scripts, and all are assigned to hot keys.

What has bugged me for a long time is that some of these marking menus (all of my user marking menus) dont work when I click in a non-viewport window, like the graph editor for example. Today I set up a marking menu for some keyframe editing so I thought I should try to find out how to make it work in the graph editor.

I found the solution by poking around in one of Hamish McKenzie's zoo scripts. Here's what I did...

I created a marking menu, called KeyFrameEdit, with the marking menu editor and specified that it should be available for editing in the Hotkey Editor. Then I opened the Hotkey Editor and located the new marking menu which is listed twice as a command in the User Marking Menus section - KeyFrameEdit_Press and KeyFrameEdit_Release.

I highlighted KeyFrameEdit_Press and assigned alt-j as the hotkey. The following mel code appears in the lower half of the Hotkey Editor.

if (`popupMenu -exists tempMM`) { deleteUI tempMM; }
popupMenu -button 1 -ctl false -alt true -sh false -allowOptionBoxes true -parent viewPanes -mm 1 tempMM;
source "menu_KeyFrameEdit";

The mel command shown is executed when I hold alt-j and left-mouse click in the viewports as expected, but to make it work in the graph editor I had to edit the command in the Hotkey Editor. Here is the result.

string $panel = `getPanel -up`;
if (`popupMenu -exists tempMM`) { deleteUI tempMM; }
if( !`control -ex $panel` ) $panel = "viewPanes";
popupMenu -button 1 -ctl false -alt true -sh false -allowOptionBoxes true -parent $panel -mm 1 tempMM;
source "menu_KeyFrameEdit";

The extra code gets the name of the window the cursor is in and to passes it to the popupMenu command.

No Comments »

No comments yet.

RSS feed for comments on this post.

Leave a comment

You must be logged in to post a comment.

Powered by WordPress | Based on a theme by Roy Tanck