DonF
December 21, 2022, 4:15pm
1
Sorry if this may have been answered elsewhere, but I couldn't seem to find a way to do this.
I have a layout named "Main" which is a single tree layout single folder pane at the root of my main drive, and a second layout named "Dual" which is also a single tree but has a dual folder layout for two specific folders.
I'd like to have a single button that toggles between them each time the button is clicked. Is there a way to do this?
lxp
December 21, 2022, 5:15pm
2
Yes, with a script.
// https://resource.dopus.com/t/create-button-to-toggle-between-two-saved-and-named-layouts/43225
// 2022-12-21
function OnClick(clickData) {
var cmd = clickData.func.command;
var tab = clickData.func.sourcetab;
cmd.deselect = false;
if (tab.lister.layout == 'Main') {
cmd.RunCommand('Prefs LAYOUT=Dual');
} else {
cmd.RunCommand('Prefs LAYOUT=Main');
}
cmd.RunCommand('Close');
}
Button as XML
<?xml version="1.0"?>
<button backcol="none" display="label" textcol="none">
<label>43225</label>
<icon1>#newcommand</icon1>
<function type="script">
<instruction>@script JScript</instruction>
<instruction>// https://resource.dopus.com/t/create-button-to-toggle-between-two-saved-and-named-layouts/43225</instruction>
<instruction />
<instruction>// 2022-12-21</instruction>
<instruction />
<instruction>function OnClick(clickData) {</instruction>
<instruction> var cmd = clickData.func.command;</instruction>
<instruction> var tab = clickData.func.sourcetab;</instruction>
<instruction> cmd.deselect = false;</instruction>
<instruction />
<instruction> if (tab.lister.layout == 'Main') {</instruction>
<instruction> cmd.RunCommand('Prefs LAYOUT=Dual');</instruction>
<instruction> } else {</instruction>
<instruction> cmd.RunCommand('Prefs LAYOUT=Main');</instruction>
<instruction> }</instruction>
<instruction />
<instruction> cmd.RunCommand('Close');</instruction>
<instruction>}</instruction>
</function>
</button>
DonF
December 24, 2022, 5:18pm
3
Thanks! Works like a charm! Much appreciated.