For a UI list context menu you can use bpy.types.UI_MT_list_item_context_menu
. So in your code snippet:
def register():
bpy.types.UI_MT_list_item_context_menu.append(draw_menu)
def unregister():
bpy.types.UI_MT_list_item_context_menu.remove(draw_menu)
To figure out the type, I executed this in the Python console and looked for the most plausible one:
blender_types = dir(bpy.types)
for blender_type in blender_types:
if 'context_menu' in blender_type:
print(blender_type)
In addition:
What type of list and which list item did the user right-click on? According to the Blender docs you can use context.button_pointer
and context.button_prop
for that. See the code example in the docs for a dump function of all the properties of button_pointer
and button_prop
.
As far as I can tell, context.button_pointer.active
is the list item the user clicked on.
context.button_prop.name
gives an indication which type of list is clicked, e.g. 'Active Shape Key Index' or 'Active Vertex Group Index'. This name is used as title at the top of the context menu:
