Add hovered property path to python context. #107280
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#107280
Loading…
Reference in New Issue
No description provided.
Delete Branch "joshm-2/blender:context_hovered_property"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem Addressed:
I frequently find myself adding small fade in/fade out animations to many different properties. I would like to make an addon that does this with a simple shortcut. I want it to work like the built-in Insert Keyframe operator, where I can hover over a property, press a button, and have the animation inserted. However, I currently have to resort to half-functional hacks to find what property is currently under the cursor. This would be much simpler if there were some way to get the currently hovered property using the Python interface.
Proposed Solution:
Add a property
context.hovered_property
which gives a string containing the path of the property currently under the user's mouse.Alternative Solutions:
The property could possibly be placed somewhere else.
Limitations:
No known limitations.
Other comments:
Please let me know if any of the changes I made to make this work are undesirable. Namely, I had to modify
bContextDataResult
to be able to carry strings in addition to RNA pointers and lists.@ideasman42 Would you be able to review this?
The functionality seems useful. But it leaks memory, while it does free the string in the Python API code this can be used in other places too and each place having to free this manually is not the right solution.
Maybe instead add a
CTX_DATA_TYPE_PROPERTY
that stores aPropertyRNA *prop
andint index
, and then do the conversion to string in the Python API code?It may also be more convenient to return this as a tuple
id, data_path, index
instead, since that is also whatkeyframe_insert
needs.I think perhaps just
property
would be a better name as well, since we don't usehovered
anywhere else even though the screen/area/region behave similarly.Can't tell you how many times I've needed this feature when writing add-ons. Thank you Josh for doing it
c44646193a
todc8a75ed77
I agree with and have incorporated your feedback. What do I need to do to add this functionality to the docs?
@brecht Since it has been a while I am realizing it may not have pinged you when I re-requested your review. Are you still available to provide feedback?
Sorry for the delay. I will commit this with documentation and a fix for the memory leak.
@ -4380,0 +4395,4 @@
const PyObject *obj_ptr_py = pyrna_struct_CreatePyObject(&parentptr);
const PyObject *path_str_py = PyUnicode_FromString(path_str);
ret = PyTuple_Pack(3, obj_ptr_py, path_str_py, PyLong_FromLong(newindex));
This leaks memory, as
PyTuple_Pack
does not steal the reference. I'll change itPyTuple_SET_ITEMS
which does.