I've managed to create a window in Blender full of controls, however the only issue is the window closes if I click outside it. I need to to remain on screen until a 'close' button is clicked.
My current code is as follows:
row.operator("wm.floating_ui", text="Open Test Window", icon='PREFERENCES')
And the class:
class CUSTOM_OT_FloatingPanel(bpy.types.Operator):
"""Floating Window with UI"""
bl_idname = "wm.floating_ui"
bl_label = "Floating Window"
bl_options = {'REGISTER', 'UNDO'}
float_value: bpy.props.FloatProperty(name="Size", default=1.0, min=0.1, max=10.0)
toggle: bpy.props.BoolProperty(name="Enable Feature", default=False)
def execute(self, context):
self.report({'INFO'}, f"Size: {self.float_value}, Toggle: {self.toggle}")
return {'FINISHED'}
def draw(self, context):
layout = self.layout
layout.label(text="Floating Window", icon='WORLD')
layout.prop(self, "float_value", slider=True)
layout.prop(self, "toggle", text="Enable Feature")
layout.operator("object.select_all", text="Select All", icon='RESTRICT_SELECT_OFF')
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self)
As mentioned this works perfectly, except it closing when clicking outside the window. Any suggestions on how to get the desired behaviour?
Thanks for any help!