2
$\begingroup$

This existing question has some answers that attempt to make a property field focused when it appears, but none of them seem to work in 2.91.

If you run the code below, you will see that the field is not selected, even though the "bl_property" value is set, per this documentation.

Here is my sample code (it is not currently useful, of course, just demonstrating the issue); the idea is to show a small window with a single property, and have that property focused:

import bpy
from bpy.props import *
theFloat = 0.0

class DialogOperator(bpy.types.Operator):
    bl_idname = "object.dialog_operator"
    bl_label = "Simple Dialog Operator"
    bl_property = "my_float"

    my_float: FloatProperty(name="Some Floating Point")

    def execute(self, context):
        global theFloat
        theFloat = self.my_float
        return {'FINISHED'}

    def invoke(self, context, event):
        global theFloat
        self.my_float = theFloat
        return context.window_manager.invoke_props_dialog(self)

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

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

if __name__ == "__main__":
    register()

bpy.ops.object.dialog_operator('INVOKE_DEFAULT')
$\endgroup$

1 Answer 1

1
$\begingroup$

bl_property does work for StringProperty, but not for FloatProperty. I have reported a bug, but I'm not sure it will qualify as such (might be more of a feature request, I'm not sure): https://developer.blender.org/T84563

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .