Hello Andreas,
thank you for the clarification, CMD_VALUE
was indeed the part that was not obvious to me. I can confirm the behavior and would also consider it to be a bug, especially since there has been a bug in 18.04 which has been fixed and was similar in nature.
There is unfortunately not much what you can do currently regarding workarounds. At least I do not see one. This is because the root of the problem lies within the handling of palettes (and might be related to/ a side effect of the fix of the 18.04 issue) and therefore far outside of the wiggle room of the public API/SDK. I have reached out to the dev who fixed the older bug, and we will see if we want to consider this to be a bug or an accepted limitation.
I will give you here a status update on what we will do once I know it.
Cheers,
Ferdinand
The pruned plugin example to reproduce this:
"""Example for buggy ExecuteOptionID behavior when a CommandData state is
c4d.CMD_ENABLED | c4d.CMD_VALUE.
As discussed in:
https://plugincafe.maxon.net/topic/13407/
"""
class PC13407(c4d.plugins.CommandData):
"""A CommandData plugin implementing GetState and being registered with
PLUGINFLAG_COMMAND_OPTION_DIALOG.
The CommandData has an internal toggle to either set it as checked, i.e.,
c4d.CMD_VALUE, or not. Which is here being toggled in Execute() and then
reflected in GetState().
The problem which then arises is that when the plugin icon is docked into
a palette, and brought into the c4d.CMD_VALUE state, that Cinema will not
distinguish properly anymore between clicks onto the major gadget, the
icon, and the cogwheel next to it. The user looses then in this state the
ability to invoke ExecuteOptionID() via clicking onto the cogwheel.
Clicking onto the cogwheel will then invoke Execute() instead.
When invoking the plugin from a menu, e.g., the Extensions menu, this does
not happen.
"""
ID_PLUGIN = 1057432
_isActive = False
def Execute(self, doc):
PC13407._isActive = not PC13407._isActive
print(f'Execute(), _isActive: {PC13407._isActive}')
return True
def ExecuteOptionID(self, doc, plugid, subid):
print('ExecuteOptionID()')
return True
def GetState(self, doc):
return (c4d.CMD_ENABLED
if not PC13407._isActive else
c4d.CMD_ENABLED | c4d.CMD_VALUE)
if __name__ == '__main__':
c4d.plugins.RegisterCommandPlugin(
id=PC13407.ID_PLUGIN,
str="Options Test",
info=c4d.PLUGINFLAG_COMMAND_OPTION_DIALOG,
icon=None,
help="",
dat=PC13407())