Solved Remove the Default CreateContextMenu in TreeViewFunctions?

Hi,

Upon RMB a TreeView item, you'll get the default Remove and Remove All.
I want to remove them but I'm having problem doing so.

Here is the working code so far:

    def CreateContextMenu(self, root, userdata, obj, lColumn, bc):

        bc = None # Delete the existing base container
        bc = c4d.BaseContainer() # Create a blank one
        bc.SetString(1231245, "Hello World!") # Add a new entry

Regards,
Ben

Hi,

As said in the documentation here you have to remove those entry in the basecontainer provided. You can override bc content like this.

for that you have several option

        # one of those  solution should work
        # 1 - flush the BaseContainer
        bc.FlushAll()
        
        # 2 - Remove data using our API
        bc.RemoveData(c4d.ID_TREEVIEW_CONTEXT_REMOVE)
        bc.RemoveData(c4d.ID_TREEVIEW_CONTEXT_RESET)
        
        # 3- Remove data using Python
        del (bc[c4d.ID_TREEVIEW_CONTEXT_REMOVE])
        del (bc[c4d.ID_TREEVIEW_CONTEXT_RESET])

Cheers,
Manuel

MAXON SDK Specialist

MAXON Registered Developer

@m_magalhaes

Thanks! It works as expected