Bug Report: menuItem -dragMenuCommand does not work as advertised

Bug Report: menuItem -dragMenuCommand does not work as advertised

FirespriteNate
Advocate Advocate
308 Views
1 Reply
Message 1 of 2

Bug Report: menuItem -dragMenuCommand does not work as advertised

FirespriteNate
Advocate
Advocate

The menuItem command has a flag -dragMenuCommand (-dmc), that the command docs describe as follows:

 

If the menu item is put on the shelf then this command will be invoked when the corresponding shelf object is clicked.

 

This suggests to me that if you don't want the regular -command contents to be put on the shelf button, then you can additionally specify this -dmc flag and it will put THAT code into the shelf button instead. This would be especially useful in Python where the -command might be a function object, rather than a string, and you do not want that on your shelfButton.

 

However, this does not seem to be the case (at least in the Maya versions I checked, 2022/23/24). If you use the -dmc flag, then the code you specify is executed IMMEDIATELY ON shelfButton creation (i.e. when you hold Shift/Ctrl and click the menuItem) and then the created shelfButton has an EMPTY command, so doesn't even take on the given -command OR -dragMenuCommand contents.

 

(Additionally, the comparible -dragDoubleClickCommand flag does appear to work exactly as expected, even though it's doc explanation is essentially identical to -dragMenuCommand).

 

Is there some trick to get this working? or is this indeed a bug?

0 Likes
309 Views
1 Reply
Reply (1)
Message 2 of 2

brentmc
Autodesk
Autodesk

Hi,

The documentation appears to be incorrect.

The dragMenuCommand will be executed immediately and that command is expected to return a string containing the actual command that will be put on the shelf button.

Searching through the Maya built-in scripts is a good way to figure out how commands are used.

menuItem  
    -dmc "performPointConstraint 2"


Many Maya commands follow this pattern. There is a script called "performSomeCommand" and it takes a single argument.

- 0 executes the command immediately
- 1 brings up the command option box 
- 2 returns the underlying command string

So a menu item could call the same script passing 0 for the command, 1 for the double-click and 2 for the drag.

This explains why you are seeing different behaviour between the drag and double-click command. They do indeed act differently!

I hope this clears things up and I will open an issue to update the menuItem command documentation.

 

Brent McPherson
Principle Engineer
0 Likes