Close Current Layout

This button will close all listers from the current layout:

In more detail:

  • If you click the button in a lister which is part of a layout, that lister will close, and any other listers which came from the same layout will also be closed.

  • If you click the button in a lister which is not part of a layout, that lister will be closed on its own, and any others will be left alone.

(If you want to close all listers, or all other listers; or if you want to collapse other listers into tabs within a single window, there are built-in commands for that, such as Close ALLLISTERS and Close ALLOTHERLISTERS. See the Close command for that.)


The script code contained in the .dcf button above is reproduced here to help people browsing the forum for scripting techniques:

function OnClick(clickData)
{
	var layout = clickData.func.command.sourcetab.lister.layout;
	if (layout == null || layout == "")
	{
		// No layout. Just close the active window.
		clickData.func.command.RunCommand("Close");
		return;
	}
	CloseLayout(layout);
}

function CloseLayout(layout)
{
	var cmd = DOpus.Create.Command();
	for(var eListers = new Enumerator(DOpus.listers); !eListers.atEnd(); eListers.moveNext())
	{
		var lister = eListers.item();
		if (lister.layout == layout)
		{
			cmd.SetSourceTab(lister.activetab);
			cmd.RunCommand("Close");
		}
	}
}

If you wanted to close a particular named layout, or make a command which can be passed a layout name to close, you could reuse the CloseLayout function from the script. Just pass it the name of the layout you wish to close.

1 Like

Thank you, this is very useful! I've been looking to see how to close all listers at once in a saved layout :):+1::slightly_smiling_face:

1 Like