Thank you for reaching out to us. As announced here, Maxon is currently conducting a company meeting. Please understand that our capability to answer questions is therefore limited at the moment.
I am slightly confused about the nature of your questions, especially in the context of the reply from @mogh.
TreeViewFunctions.GetDropDownMenu lets you define the content of drop down menus in a
TreeView, and the slightly ill named
SetDropDownMenu lets you react to an item being selected in such menu.
The 'problem' with your code snippet is that you do not differentiate the drop down gadgets which are set in
GetDropDownMenu. Like many methods of
TreeViewFunctions it is called for each cell in the tree view table, where
lColumn denotes the column as defined in your TreeViewCustomGui.SetLayout call, and
obj denotes an item in your
root, so sort of the row in the tree.
lColumn becomes meaningless when your tree view has only one column of type
LV_DROPDOWN. How to make sense of
obj, depends on the shape of the data you passed as
root. When root
root is just a
list[object], you could for example alternate between even and odd rows like this.
self, root: list[object], userdata: any, obj: object, lColumn: int, menuInfo: dict):
"""Simple example for defining the menu content based on the position of #obj in #root.
index: int = root.index(obj)
if index % 2 == 0:
menuInfo["menu"] = "Even row first option"
menuInfo["menu"] = "Even row second option"
menuInfo["menu"] = "Odd row first option"
menuInfo["menu"] = "Odd row second option"
menuInfo["state"] = int(menuInfo["state"])
In practice, the content of a drop down is more likely to be determined based on the fields of
if obj.a == "foo" then Menu1 else Menu2)rather than its relative position in
root (be it a list-like or tree-like data structure).