How to make field focused in props dialog?

I have a script, that create a dialog with one text input:

import bpy

class OFPropConfirmOperator(bpy.types.Operator):
    bl_idname = "view3d.custom_confirm_dialog"
    bl_label = "Generite output folders"

    prop1 = bpy.props.StringProperty()

    @classmethod
    def poll(cls, context):
        return True

    def execute(self, context):
        #do some stuff here
        return {'FINISHED'}

    def invoke(self, context, event):
        return context.window_manager.invoke_props_dialog(self)

    def draw(self, context):
        row = self.layout
        row.prop(self, "prop1", text="New name")


class OFPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_idname = "OF_my_panel"
    bl_label = "OF"
    bl_space_type = "VIEW_3D"
    bl_region_type = "TOOLS"
    bl_category = "Tools"

    def draw(self, context):
        layout = self.layout
        layout.operator(OFPropConfirmOperator.bl_idname)

def register():
    bpy.utils.register_class(OFPropConfirmOperator)
    bpy.utils.register_class(OFPanel)

def unregister():
    bpy.utils.unregister_class(OFPanel)
    bpy.utils.unregister_class(OFPropConfirmOperator)

if __name__ == "__main__":
    register()

So, I have a button on the T-panel, that in the panel called OFPanel, this button opens the OFPropConfirmOperator` pop-up window. And everything works fine, but then the pop-up window opens, I need to click on the text field to start editing it. But I want it to work like in renaming markers: then a pop-up window opens, you can edit the text at once

It’s quite hidden, but you can add this to the operator:

    bl_property = "prop1"

https://docs.blender.org/api/blender_python_api_master/bpy.types.Operator.html#bpy.types.Operator.bl_property

2 Likes