Python tool set/unset Handlers #118026
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#118026
Loading…
Reference in New Issue
No description provided.
Delete Branch "JaumeBellet/blender:pr-0021-tool-handlers"
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?
This patch allows to create a Callback function on python, that is being
executed on operator change (set / unset)
Applies updated diff from https://archive.blender.org/developer/D10635
Adds a handler object on ToolDef, with 'set' 'unset' containing and array of callback function for the tool.
Example code
apply updated diff from https://archive.blender.org/developer/D10635to Python tool set/unset HandlersSomething like this is exactly what I need for an Edit WorkSpaceTool that I'm developing so I can determine when someone activates or deactivates the tool. Right now, Blender's tool system doesn't appear to have this functionality and I have to use a timer to detect tool changes.
However, this pull request needs some work. Right now you cannot use it to setup the handlers in the addon's
register
andunregister
methods which I think is a requirement for inclusion in Blender.I added two commits.
The first one, allows to set the handler on the tool using the data returned by register_tool, so you don't need the context at all.
The second one allows to specify the mode on
item_from_id
so it does not use the context. It was possible, only bypassed the value, so i don't know if there maybe other some cases when context is needed.Also fixed issue when the selected tool was saved on file, and not available on blender startup.
Allow to set callback functions in WorkSpaceTool Class . This way the final code is cleaner.
Previous procedures allows you to set callbacks over other tools you have not defined, that is great for expanding some kind of functionality.
Checkout
From your project repository, check out a new branch and test the changes.