(UI) Highlight menu items [with green brackets]


#1

Hi,

Is it possible to highlight custom menu items with those green brackets?image


#2

Yes, you can get QMenu items and dump them for inspection. Did some to custom color menu items in the node editor fiddling around with it. The dump will however be a huge trove of “QMenuItems##” and so on so to find the correct one might be a pain using the same method I used. If you add the menu items yourself with Qt you should however know how to access your items.


#3

Damn.

I was hoping to do that without QT as I don’t have any experience with that.

Anyway, Thank you!


#4

Found the python tab I had the code in when I looked into this, maybe it could help.

import pymel.core as pm      


def recursive_children(qt_object, level=0):
    
    print '  ' * level + type(qt_object).__name__    
    children = qt_object.children()
    
    for child in children:        
        recursive_children(child, level)    
        level += 1
        

def widget_parser(widget):
    """ Recursive listing of a widgets structure, """
    children = widget.children()
    
    for child in children:
        
        print type(child).__name__
    
    
# Get the node editor as a Qt object,
node_editor = pm.getPanel(scriptType='nodeEditorPanel')[0]
node_editor_qt = node_editor.asQtObject()

widget_parser(node_editor_qt)
recursive_children(node_editor_qt)

#5

Probably the easiest way to do this is just use the version flag on cmds.menuItem, if the version value == the current running version of Maya, it will highlight. Otherwise it won’t.

If you’re using mel, and maya LT, you need to use ltVersion instead.


#6

wow. appreciate the code. i’ll look into this. it is due to get some basic qt knowledge at least.


#7

Well, that’s embarrasing. I’ve tried using this flag before. Must have done something wrong it seems.

Thank you!!


#8

@cur10us you should mark Bob’s answer as the ‘solution’ so future lurkers know there’s a definitive answer…


#10

sorry for late response. i can’t seem to find how to mark an answer as the solution


#11

OK, I did it. Looks like there was a plugin setting that changed a version ago, hiding the option.