Is it possible to control invoke_props_dialog buttons?

hi everyone,
is it possible to show only the OK button in invoke_props_dialog dialog? currently by default, it shows OK and CANCEL, but in earlier versions, it used to show only the OK button!

Generally we prefer to have both a confirm and cancel button, but for special occasions this will probably help you:

2 Likes

thank you @Harleya !

I do not know what I am doing wrong, but if I pass empty string to the function template_popup_confirm as the operator, I get the default behavior (two buttons) .

If I pass bl_idname of the same class, I get the desired UI, but infinite loop of dialogs if I keep pressing the OK button.

any suggestions?

btw, the code I am editing is part of the MustardSimplify addon :

import bpy


class MUSTARDSIMPLIFY_OT_MenuBlenderSimplifySettings(bpy.types.Operator):
    """Modify Blender Simplify settings"""
    bl_idname = "mustard_simplify.menu_blender_simplify_settings"
    bl_label = "Blender Simplify Settings"

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

    def execute(self, context):
        return {'FINISHED'}

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

    def draw(self, context):

        scene = context.scene

        layout = self.layout
        layout.use_property_split = True
        rd = scene.render

        box = layout.box()

        box.label(text="Viewport", icon="RESTRICT_VIEW_ON")

        flow = box.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True)

        col = flow.column()
        col.prop(rd, "simplify_subdivision", text="Max Subdivision")
        col = flow.column()
        col.prop(rd, "simplify_child_particles", text="Max Child Particles")
        col = flow.column()
        col.prop(rd, "simplify_volumes", text="Volume Resolution")
        col = flow.column()
        col.prop(rd, "use_simplify_normals", text="Normals")

        box = layout.box()

        box.label(text="Render", icon="RESTRICT_RENDER_ON")

        flow = box.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True)

        col = flow.column()
        col.prop(rd, "simplify_subdivision_render", text="Max Subdivision")
        col = flow.column()
        col.prop(rd, "simplify_child_particles_render", text="Max Child Particles")
        
        # MY ADDED CODE IS THE NEXT LINE
        layout.template_popup_confirm("", text="Okkey!", cancel_text="")


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


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

the last line of the draw method is my edition!

I haven’t explored that template_popup_confirm very much, mostly just testing it to see that it worked.

What it the use case though? Are you wanting a purely informational “info”-style popup to inform the user of something and then just have them dismiss with an “okay”? Or does the confirm really do something and you just wanting to remove the cancel for some reason? Does the operation not have an applicable cancel?

1 Like

I edited the previous reply!
actually the code change simplify settings on the fly inside a modal, so here cancel is just misleading since it does not cancel the changes.