Hey @Gene,
Thread-necromancy is often not so good, because it almost always derails the original topic and often also lacks in clarity. I also here do not understand what your concrete question is?
When I click on the Quicktab, the first event returns True, while the second returns False.
What do you mean by "the event returns true"? It is you, the developer, who returns the result for an event (or you do not handle it at all). Are you talking about something like BFM_ACTION_VALUE?
If I drag over two entries on the Quicktab gadget (click on one entry, then drag to the next entry and let go of the mouse,) Command triggers three times, msg[c4d.BFM_ACTION_INDRAG] returns True the first two times and False for the last one. Also, the first entry returns True for its IsSelected() check on mouse down. After dragging, the the second entry's IsSelected() is True. Second entry's IsSelected() is also true when I let go of the mouse.
I do not see any question here, so what is the goal?
Regarding Command triggering twice, is it because of the mouse events?
GeDialog.Command is just a convenience wrapper for GeDialog.Message events (most from the BFM_ACTION family). If you want the full picture, use Message. I struggle to see a tangible question which I could answer, what do you want to achieve?
Yes, some controls fire multiple times in Command, it is impossible (and also somewhat futile) to reconstruct the reason for each of them. Someone thought at some point it would be convenient to forward this kind of event to Command for some feature in Cinema 4D.
I am not familiar with the exact issue discussed in this topic, but at a glance, what Maxime wrote then looks a bit overkill with the hashing, I would just store the last selected element and be done with it. Alternatively you could design your code so that you do not tie any heavy logic to a tab being activated (which is IMHO not a great idea in general), so that you do not mind when such code runs multiple times.
Cheers,
Ferdinand
class MyDialog (c4d.gui.GeDialog):
ID_TAB_1: int = 10000
ID_TAB_2: int = 10001
IDS_TABS: tuple[int, ...] = (ID_TAB_1, ID_TAB_2)
def __init__(self) -> None:
self._activeTab: int = MyDialog.ID_TAB_1
def Command(self, cid: int, msg: c4d.BaseContainer) -> bool:
"""
"""
if cid == self._activeTab:
return True
elif cid in MyDialog.IDS_TABS:
self._activeTab = cid
if cid is MyDialog.ID_TAB_1:
foo()
elif cid is MyDialog.ID_TAB_2:
bar()
return True