Hello @simonator420,
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.
def GetDropDownMenu(
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"][1000] = "Even row first option"
menuInfo["menu"][1001] = "Even row second option"
else:
menuInfo["menu"][1000] = "Odd row first option"
menuInfo["menu"][1001] = "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 obj
(e.g., 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).
Cheers,
Ferdinand