Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMSUSD-715 fix context menu in viewport #3404

Merged
merged 3 commits into from
Oct 24, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions plugin/adsk/scripts/USDMenuProc.mel
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ global proc USDMenuProc(string $parent, string $obj)
{
$obj = expandToSelection($obj);

popupMenu -e -dai $parent;
setParent -menu $parent;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous code also had setParent -menu ..;

Note: this doesn't actually create the menu - it is created by Maya. What this is doing is clearing out the menu and then setting it for subsequent menuItem calls.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A! Well, the bug was in Maya, buildNonMayaContextMenu calls MEL command that fail because there are no menu active. So something in those two lines does the trick. I wrote those because they were in here before my previous change to use the UFE context menu, so I thought they were needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you got the right line, we can commit it with "suggested code changes" in this review.

Copy link
Collaborator

@seando-adsk seando-adsk Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually confused why the previous code also had setParent -menu .. - the line above set the menu parent and then this one would make it move up one level.

Can you do a test and print out what the original parent is and what the calls to the two different setParent would be?

Note: this menu is actually called from two different places in Maya, so make sure to test both of those.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem being fixed here is that as reported sometimes the parent is not a menu and does not have a popup menu. The version without the popuMenu call would only work by a happy accident most of the time. I'll check what were the parent when it work and did not work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

he parent being passed in is for example "MainPane|viewPanes|modelPanel4|modelPanel4|modelPanel4|modelPanel4ObjectPop". What is needed is to set it as the parent to be used by the menu being created.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for checking. I wonder if we should leave in the popupMenu -e -dai $parent; which would clear the menu of all items (in case it has any) as we are going to populate it with MayaUsd menu items.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll put it back then.

python("import maya.app.ufe.outlinerSupport; maya.app.ufe.outlinerSupport.buildNonMayaContextMenu('''" + $obj + "''')");

// Allow the user to define a proc with additional menu items
Expand Down
Loading