Finding what code is triggered by a UI element

Are the below docs outdated? When I hover over UI elements; I do not see a name for the operator that will be invoked; and searching for the referenced code snippets doesn’t always get results.

https://wiki.blender.org/wiki/Reference/FAQ
How are Operators connected to C code?

Is there a way to find which bit of Python generates an given bit of the UI; and then to figure what gets invoked when things are clicked?

Thanks

You need to enable the tooltips in the preferences. In Preferences > Interface make sure Tooltips, Python Tooltips, and Developer Extras are checked. Then you should see more details in the tooltips.

image

You will also see an Edit Source entry when you right click on UI elements. This opens the .py file in the text editor. (This button is in properties_object.py)

image

As an example, if you were searching for the operator object.collection_link() I would follow the guidelines in the wiki you linked.

$ grep -rn OBJECT_OT_collection_link
editors/object/object_ops.c:242:  WM_operatortype_append(OBJECT_OT_collection_link);
editors/object/object_collection.c:518:void OBJECT_OT_collection_link(wmOperatorType *ot)
editors/object/object_collection.c:524:  ot->idname = "OBJECT_OT_collection_link";
editors/object/object_intern.h:289:void OBJECT_OT_collection_link(struct wmOperatorType *ot);

Searching for just collection_link will also work.

From there, look at those functions that the search found. This is the process I follow when I’m trying to locate code I’ve never edited before, and by searching the operator name, tooltip name, and description, I’m usually able to find it quickly.

2 Likes

Fantastic; updating Preferences did the trick! thank you very much

1 Like