Gizmo : "target_set_handler" doesn't show the tooltip description when the mouse moves over the Gizmo. #73033

Closed
opened 2020-01-10 22:24:40 +01:00 by Cédric · 4 comments
Member

System Information
Operating system: Windows-10-10.0.17763-SP0 64 Bits
Graphics card: GeForce GTX 1080 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 441.66

Blender Version
Broken: version: 2.82 (sub 6), branch: master, commit date: 2020-01-10 06:10, hash: 95200045f3

Short description of error
When using the "target_set_prop" to update the offset of the gizmo, we can see a tooltip on the screen when the pointer moves over the gizmo.
When using the "target_set_handler", there is no tooltip anymore.

Exact steps for others to reproduce the error
Using default scene and the factory setting,
In the preferences, check for the "Tooltips" checkbox.
Select the lamp and set the power to "1" to see the Gizmo.
Copy/Paste and execute the following script : There is no tooltip when the mouse moves over the gizmo.
Comment the lines 31 to 42 and uncomment the line 46, then execute the script again : There is a tooltip when the mouse moves over the gizmo.

Or use the following file :
handler_gizmo.blend

Thanks for your help.

- Example of a group that edits a single property
- using the predefined gizmo arrow.
#
- Usage: Select a light in the 3D view and drag the arrow at it's rear
- to change it's energy value.
#
import bpy
from bpy.types import (
    GizmoGroup,
)


class MyLightWidgetGroup(GizmoGroup):
    bl_idname = "OBJECT_GGT_light_test"
    bl_label = "Test Light Widget"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'WINDOW'
    bl_options = {'3D', 'PERSISTENT'}

    @classmethod
    def poll(cls, context):
        ob = context.object
        return (ob and ob.type == 'LIGHT')

    def setup(self, context):
        # Arrow gizmo has one 'offset' property we can assign to the light energy.
        ob = context.object
        mpr = self.gizmos.new("GIZMO_GT_arrow_3d")
        
        ### No tooltip : Comment this part ####
        def get_energy():
            ob = context.object
            offset = ob.data.energy
            return offset

        def set_energy(offset):
            ob = context.object
            ob.data.energy = offset

        
        mpr.target_set_handler('offset', get=get_energy, set=set_energy)
        mpr.use_draw_value = True
        #########################
                
            - Uncomment this part to see the tooltip ####
- mpr.target_set_prop("offset", ob.data, "energy")
        #########################
        

        mpr.matrix_basis = ob.matrix_world.normalized()
        mpr.draw_style = 'BOX'

        mpr.color = 1.0, 0.5, 0.0
        mpr.alpha = 0.5

        mpr.color_highlight = 1.0, 0.5, 1.0
        mpr.alpha_highlight = 0.5


        self.energy_widget = mpr

    def refresh(self, context):
        ob = context.object
        mpr = self.energy_widget
        mpr.matrix_basis = ob.matrix_world.normalized()


bpy.utils.register_class(MyLightWidgetGroup)

**System Information** Operating system: Windows-10-10.0.17763-SP0 64 Bits Graphics card: GeForce GTX 1080 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 441.66 **Blender Version** Broken: version: 2.82 (sub 6), branch: master, commit date: 2020-01-10 06:10, hash: `95200045f3` **Short description of error** When using the "target_set_prop" to update the offset of the gizmo, we can see a tooltip on the screen when the pointer moves over the gizmo. When using the "target_set_handler", there is no tooltip anymore. **Exact steps for others to reproduce the error** Using default scene and the factory setting, In the preferences, check for the "Tooltips" checkbox. Select the lamp and set the power to "1" to see the Gizmo. Copy/Paste and execute the following script : There is no tooltip when the mouse moves over the gizmo. Comment the lines 31 to 42 and uncomment the line 46, then execute the script again : There is a tooltip when the mouse moves over the gizmo. Or use the following file : [handler_gizmo.blend](https://archive.blender.org/developer/F8268994/handler_gizmo.blend) Thanks for your help. ``` - Example of a group that edits a single property - using the predefined gizmo arrow. # - Usage: Select a light in the 3D view and drag the arrow at it's rear - to change it's energy value. # import bpy from bpy.types import ( GizmoGroup, ) class MyLightWidgetGroup(GizmoGroup): bl_idname = "OBJECT_GGT_light_test" bl_label = "Test Light Widget" bl_space_type = 'VIEW_3D' bl_region_type = 'WINDOW' bl_options = {'3D', 'PERSISTENT'} @classmethod def poll(cls, context): ob = context.object return (ob and ob.type == 'LIGHT') def setup(self, context): # Arrow gizmo has one 'offset' property we can assign to the light energy. ob = context.object mpr = self.gizmos.new("GIZMO_GT_arrow_3d") ### No tooltip : Comment this part #### def get_energy(): ob = context.object offset = ob.data.energy return offset def set_energy(offset): ob = context.object ob.data.energy = offset mpr.target_set_handler('offset', get=get_energy, set=set_energy) mpr.use_draw_value = True ######################### - Uncomment this part to see the tooltip #### - mpr.target_set_prop("offset", ob.data, "energy") ######################### mpr.matrix_basis = ob.matrix_world.normalized() mpr.draw_style = 'BOX' mpr.color = 1.0, 0.5, 0.0 mpr.alpha = 0.5 mpr.color_highlight = 1.0, 0.5, 1.0 mpr.alpha_highlight = 0.5 self.energy_widget = mpr def refresh(self, context): ob = context.object mpr = self.energy_widget mpr.matrix_basis = ob.matrix_world.normalized() bpy.utils.register_class(MyLightWidgetGroup) ```
Author
Member

Added subscriber: @Clarkx

Added subscriber: @Clarkx

Added subscriber: @iss

Added subscriber: @iss

Changed status from 'Needs Triage' to: 'Archived'

Changed status from 'Needs Triage' to: 'Archived'
Richard Antalik self-assigned this 2020-01-12 16:41:38 +01:00

I really don't know how this is implemented, but seems you should use both target_set_prop() and target_set_handler()

        ...
        mpr.use_draw_value = True
        mpr.target_set_prop("offset", ob.data, "energy")
        mpr.target_set_handler('offset', get=get_energy, set=set_energy)
        ...

I would suggest discussing issues like these in https://devtalk.blender.org
This portal is strictly for bugs.

I really don't know how this is implemented, but seems you should use both `target_set_prop()` and `target_set_handler()` ``` ... mpr.use_draw_value = True mpr.target_set_prop("offset", ob.data, "energy") mpr.target_set_handler('offset', get=get_energy, set=set_energy) ... ``` I would suggest discussing issues like these in https://devtalk.blender.org This portal is strictly for bugs.
Sign in to join this conversation.
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
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#73033
No description provided.