PDA

View Full Version : Editable menu ?


jojanpm
12-08-2010, 04:48 AM
How can we create an editable menu using MEL/Python, as in Qt?
We are using Maya 2009; No Qt.

jojanpm
12-08-2010, 04:52 AM
.. And i need a solution other than popupMenu (because it will always show all items).

djx
12-08-2010, 08:57 AM
Most types of menus can be edited in some way. If you want to add and remove items, maybe have your script build the menu from scratch each time you need it. One example of this kind of thing can be seen in dagMenuProc.mel

David

jojanpm
12-08-2010, 09:25 AM
no no.. i meant, the user should be able to enter a new value into an already loaded menu.
in Qt, its possible if we set the 'editable' attribute to true.

djx
12-08-2010, 10:23 AM
All my rmb menus are editable thanks to dagMenuProc and the zooObjMenu mel scripts (zooToolbox). Users can add new commands and edit existing commands through a simple UI launcehd from the rmb-menu, rather than directly on the rmb-menu itsself, but the functionality is the same. In this case the commands are context sensitive and linked to the objects, but you could easily generalize that.

David

NaughtyNathan
12-08-2010, 12:57 PM
you don't need to make a menu editable, or make an editable menu. Basically all UI in MEL/Maya is editable by default.

As long as you know the name of the UI object you want to edit you can edit it, so in the case of a menu, you just setParent to the menu (or use menuItem -parent), then use menuItem -insertAfter to add a new menu item to it. job done.

or, as djx has already alluded to, you use a menu's -pmc flag to rebuild it every time it opens. this may seem excessive or inefficient, but it's really not, and is how 50% of Maya's menus already work, including most pop-up menus.

:nathaN

CGTalk Moderation
12-08-2010, 12:57 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.