Sub menus in shelf button


#1

Hello, I need some help with Mel in which I am trying to attach a sub-menu onto a shelf button.

If the shelf button is toggled by left-mouse click (also the default), a menu will be shown.
And if it is toggled with a right-mouse click, a different menu will be shown.

This is my code:

shelfButton
    -enableCommandRepeat 1
    -enable 1
    -noDefaultPopup
    -width 34
    -height 34
    -manage 1
    -visible 1
    -preventOverride 0
    -align "center"
    -label "Set Rig Options"
    -labelOffset 0
    -font "tinyBoldLabelFont"
    -image "myTestIcon.png"
    -backgroundColor 0.25 0.25 0.25
    -style "iconOnly"
    -marginWidth 1
    -marginHeight 1
    -sourceType "python"
    -command "import moduleA; menuA=moduleA.dropdown_from_selection(); moduleA.showMenu(menuA)";

    // When right-mouse click is toggled.
    popupMenu -b 3;
        // I need to give the label a name, otherwise Maya will auto-provide a name such as 'menuitem1993' etc.
        menuItem -l "testing" -sourceType "python" -command "import moduleB; menuB= moduleB.dropdown_from_selection(); moduleB.show_menu(menuB)";

FYI - both menus - menuA and menuB are created/ generated using QMenu.

However, in the case of right-mouse click, it has to go through the label, before the actual menu is shown. Is there anyway, in which I can bypass this label, or if there is a better way in which I can handle both left and right mouse click?