On Sat, Oct 26, 2019, 7:53 AM kiteh <kiteh.0...@gmail.com> wrote:

> Hi everyone,
>
> I have a shelf button that has a popup menu when performing a right mouse
> click.
> These shelf button and menu are created using mel.
>
> In the menu item of the popup menu, the menuItem within is actually a
> checkbox option where it co-relates to a pyqt checkbox within a tool that
> was driven by an cmds.optionsVar that determines if that tool mode is on/
> off.
>
> Currently I am having issues withe the menuItem checking as it does not
> seems to be checking it correctly.
> 1. If the tool is not launched, checking the menuItem seems to be working
> correctly
> 2. If the tool is launched (where the checkbox option is set to be
> unchecked), the menuItem is shown as checked. Or whether I checked/
> unchecked the option within the tool, the menuItem is not reflecting
> correctly.
>
> global proc int getState()
> {
>     int $auto_state = `optionVar -q "myToolState"`;
>     if ($auto_state == 1){
>         return false;
>     }
>     return true;
> }
>
>
> global proc animShelfFuncs_myToolButton( string $parent )
> {
>     shelfButton
>         -enableCommandRepeat 0
>         -enable 1
>         -noDefaultPopup
>         -width 34
>         -height 34
>         -manage 1
>         -visible 1
>         -label "MyTool [right click for options]"
>         -image "myTool.png"
>         -backgroundColor 0.499 0.365 0.357
>         -style "iconOnly"
>         -sourceType "python"
>         -command "import myTool; myTool.MyUI()"
>         ("shelfButton_" + $parent + "_myToolButton");
>         popupMenu -b 3;
>             menuItem -checkBox (`optionVar -q "myToolState"`) -stp
> "python" -l "myTool Mode" -c "import myTool; amyTool.toggle_mode()";
>
>
>             //if (getState()){
>             //    menuItem -checkBox true -stp "python" -l "myTool Mode"
> -c "import myTool; amyTool.toggle_mode()";
>             //}else {
>             //    menuItem -checkBox false -stp "python" -l "myTool Mode"
> -c "import myTool; amyTool.toggle_mode()";
>             //}
> }
>
> I tried 2 ways of setting the menuItem checking but both methods does not
> seems to be helping. Wondering if anyone has done anything similar?
>


In your getState() you negate the value of the optionVar but then in your
commented code you treat the value as the opposite again. Is this expected?
Because it lines up potentially with the PyQt checkbox being the opposite
of the shelf menu.
Your shelf checkbox triggers a python toggle function that we can't see.
What does this do? Is it possible that if you are really only toggling the
check value in your tool that it could be out of sync with the shelf
checkbox? Ideally it would use an explicit setting of checked or not to
prevent them from being in the wrong initial conditions and always toggling
backwards.
Does your tool know about the optionVar or does it only take its cue from
the toggle request?

-- 
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/ad36ec19-6465-4b94-af2c-a37e427deeae%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/ad36ec19-6465-4b94-af2c-a37e427deeae%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2hWJLnnSURzi-Ry81NdmO%2B2bD7rJME6S-wAHT7OX3dRQ%40mail.gmail.com.

Reply via email to