Inserting items into dropbox to TreeView
-
Hi,
could you please help with adding options to dropbox in column material in treeview?Thank you!
-
Hi @simonator420 for this purpose you have to define GetDropDownMenu and SetDropDownMenu.
GetDropDownMenu
is called by Cinema 4D to retrieve the content of the menu to display from themenuInfo
dictionary. For more information about this dictionary please have a look at TreeViewDropDownMenuInfo Dict.
SetDropDownMenu
is called by Cinema 4D when the user select a value from the dropdown.Find bellow an implementation example:
def GetDropDownMenu(self, root, userdata, obj: Entry, lColumn, menuInfo): menuInfo["entry"] = 1001 # Select teh second entry menuInfo["menu"][1000] = "First Entry" menuInfo["menu"][1001] = "Second Entry" menuInfo["menu"][1002] = "ThirdEntry" menuInfo["state"] = int(menuInfo["state"]) # Workaround to not have warning in Cinema 4D. Will be fixed in the next C4D version. def SetDropDownMenu(self, root, userdata, obj, lColumn, entry): print(f"User selected the entry with the ID: {entry}")
Finally note that due to an issue that will be fixed in the upcoming version of Cinema 4D, even if you do not change the state, you need to override it to an int value otherwise it will print an error in the console (this is not blocking but still).
Cheers,
Maxime. -
This post is deleted! -
This post is deleted!