Python API: add bpy.context.property, for property under the mouse cursor

This can be useful for example to add custom operators to the property
context menu.

Pull Request: https://projects.blender.org/blender/blender/pulls/107280
This commit is contained in:
Josh Maros
2023-04-29 20:31:27 -07:00
committed by Brecht Van Lommel
parent ea937b304d
commit 6ba0346797
6 changed files with 88 additions and 5 deletions

View File

@@ -0,0 +1,10 @@
"""
Get the property associated with a hovered button.
Returns a tuple of the datablock, data path to the property, and array index.
"""
# Example inserting keyframe for the hovered property.
active_property = bpy.context.property
if active_property:
datablock, data_path, index = active_property
datablock.keyframe_insert(data_path=data_path, index=index, frame=1)