Page MenuHome

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

Description

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

Event Timeline

Yichen DOu (Yichen-Dou) changed the task status from Needs Triage to Needs Information from User.Apr 26 2020, 3:54 PM
Yichen DOu (Yichen-Dou) created this task.
Yichen DOu (Yichen-Dou) changed the task status from Needs Information from User to Needs Triage.Apr 26 2020, 3:58 PM
Yichen DOu (Yichen-Dou) updated the task description. (Show Details)
Julian Eisel (Severin) changed the task status from Needs Triage to Confirmed.EditedApr 26 2020, 4:42 PM
Julian Eisel (Severin) changed the subtype of this task from "Report" to "Bug".

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.)

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

Julian Eisel (Severin) changed the subtype of this task from "Bug" to "Known Issue".

Part of T73565.