Cannot use keyframes, File select, File picker (eyedropper), etc. in modal Operators/Panels called by WindowManager #76124

Open
opened 2020-04-26 15:54:28 +02:00 by Yichen DOu · 8 comments

System Information
Operating system: Win10
Graphics card: Nvidia GTX 1060 6G

Blender Version
Broken: 2.82
Worked: None

Short description of error
Cannot use keyframes, File select, File picker (eyedropper), etc. in modal Operators/Panels called by WindowManager

Exact steps for others to reproduce the error
For example, this is an operator called by WM to manipulate the location of the selected object. We cannot insert keyframes to the property from RMB > Insert Keyframe or from the anim dot after the property

import bpy

class HelloWorldOperator(bpy.types.Operator):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Modal Operator"
    bl_idname = "test.hello"

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = True

        obj = context.active_object

        layout.label(text="Hello world!", icon='WORLD_DATA')
        layout.prop(obj, 'location')
    
    def execute(self, context):
        return {'FINISHED'}
    
    def invoke(self, context, event):
        wm = context.window_manager
        return wm.invoke_props_dialog(self)


def register():
    bpy.utils.register_class(HelloWorldOperator)


def unregister():
    bpy.utils.unregister_class(HelloWorldOperator)


if __name__ == "__main__":
    register()
    bpy.ops.test.hello('INVOKE_DEFAULT')

This kind of problem exists in all modal-like panels or operators called by WM. The file picker from file_select is also not working. Is it RNA problem? I hope developer can generate its error message in the console. For now, I don't know what to do next. Please let me know how can I insert keyframes to properties in such panel/operators with right click

Best wishes, thank u

**System Information** Operating system: Win10 Graphics card: Nvidia GTX 1060 6G **Blender Version** Broken: 2.82 Worked: None **Short description of error** Cannot use keyframes, File select, File picker (eyedropper), etc. in modal Operators/Panels called by WindowManager **Exact steps for others to reproduce the error** For example, this is an operator called by WM to manipulate the location of the selected object. We cannot insert keyframes to the property from RMB > Insert Keyframe or from the anim dot after the property ``` import bpy class HelloWorldOperator(bpy.types.Operator): """Creates a Panel in the Object properties window""" bl_label = "Hello World Modal Operator" bl_idname = "test.hello" def draw(self, context): layout = self.layout layout.use_property_split = True layout.use_property_decorate = True obj = context.active_object layout.label(text="Hello world!", icon='WORLD_DATA') layout.prop(obj, 'location') def execute(self, context): return {'FINISHED'} def invoke(self, context, event): wm = context.window_manager return wm.invoke_props_dialog(self) def register(): bpy.utils.register_class(HelloWorldOperator) def unregister(): bpy.utils.unregister_class(HelloWorldOperator) if __name__ == "__main__": register() bpy.ops.test.hello('INVOKE_DEFAULT') ``` This kind of problem exists in all modal-like panels or operators called by WM. The file picker from file_select is also not working. Is it RNA problem? I hope developer can generate its error message in the console. For now, I don't know what to do next. Please let me know how can I insert keyframes to properties in such panel/operators with right click Best wishes, thank u
Author

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Author

Added subscriber: @Yichen

Added subscriber: @Yichen
Author

Changed status from 'Needs User Info' to: 'Needs Triage'

Changed status from 'Needs User Info' to: 'Needs Triage'
Member

Added subscriber: @JulianEisel

Added subscriber: @JulianEisel
Member

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

Changed status from 'Needs Triage' to: 'Confirmed'
Member

This specific issue can actually be fixed quite easily:

diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 908a4a64efd..7f9cbb9bb3f 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -8258,7 +8258,8 @@ static bool ui_context_rna_button_active_test(uiBut *but)
 }
 static uiBut *ui_context_rna_button_active(const bContext *C)
 {
-  return ui_context_button_active(CTX_wm_region(C), ui_context_rna_button_active_test);
+  ARegion *region = CTX_wm_menu(C) ? CTX_wm_menu(C) : CTX_wm_region(C);
+  return ui_context_button_active(region, ui_context_rna_button_active_test);
 }
 
 uiBut *UI_context_active_but_get(const struct bContext *C)

It's something we thought about doing before (because it's technically the correct thing to do), but it didn't seem to fix other related issues. I'd like to check on possible side-effects before committing.

(Removing the Python/Add-ons project because it's a general UI code issue, not limited to Python usage.)

This specific issue can actually be fixed quite easily: ``` diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 908a4a64efd..7f9cbb9bb3f 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -8258,7 +8258,8 @@ static bool ui_context_rna_button_active_test(uiBut *but) } static uiBut *ui_context_rna_button_active(const bContext *C) { - return ui_context_button_active(CTX_wm_region(C), ui_context_rna_button_active_test); + ARegion *region = CTX_wm_menu(C) ? CTX_wm_menu(C) : CTX_wm_region(C); + return ui_context_button_active(region, ui_context_rna_button_active_test); } uiBut *UI_context_active_but_get(const struct bContext *C) ``` It's something we thought about doing before (because it's technically the correct thing to do), but it didn't seem to fix other related issues. I'd like to check on possible side-effects before committing. (Removing the Python/Add-ons project because it's a general UI code issue, not limited to Python usage.)
Author

Thank you for your reply. It helps. I will try your method too to see if it's suitable for my project

Thank you for your reply. It helps. I will try your method too to see if it's suitable for my project
Member

Part of #73565.

Part of #73565.
Philipp Oeser removed the
Interest
User Interface
label 2023-02-10 09:24:31 +01:00
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#76124
No description provided.