Here's a little add-in that should do what you want. Give it a try and let me know what you think.
function OnInit(initData) {
initData.name = 'SaveSelection';
initData.version = '2024-08-14';
initData.url = 'https://resource.dopus.com/t/remeber-the-focused-file-folder-as-you-navigate/52274/6';
initData.desc = 'Save and restore selected items';
initData.default_enable = true;
initData.min_version = '12.0';
}
function OnBeforeFolderChange(beforeFolderChangeData) {
if (beforeFolderChangeData.initial) return;
var tab = beforeFolderChangeData.tab;
var tabID = String(tab.path);
tab.vars.Set(tabID, tab.selected);
}
function OnAfterFolderChange(afterFolderChangeData) {
var tab = afterFolderChangeData.tab;
if (!tab) return;
if (!tab.path) return;
var tabID = String(tab.path);
if (!tab.vars.Exists(tabID)) return;
var cmd = DOpus.Create().Command();
cmd.SetSourceTab(tab);
// cmd.SetFiles(tab.vars.Get(tabID));
cmd.ClearFiles();
cmd.AddFiles(tab.vars.Get(tabID));
cmd.RunCommand('Select NONE');
cmd.RunCommand('Select FROMSCRIPT SETFOCUS');
cmd.RunCommand('Select SHOWFOCUS');
}
Save EventSaveSelection.js.txt toββββ
%appdata%\GPSoftware\Directory Opus\Script AddIns
This button will switch the script on and off
XML
<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
<label>SaveSelection Script is %1</label>
<tip>Toggle EventSaveSelection.js</tip>
<icon1>#script</icon1>
<function type="normal">
<instruction>@eval:scriptIsOff = IsChecked("Prefs SCRIPTDISABLE=EventSaveSelection.js*")</instruction>
<instruction>@icon:=scriptIsOff ? "setoff" : "setdest"</instruction>
<instruction>@label:Format(original_label, (scriptIsOff ? "off" : "<b>on</b>"))</instruction>
<instruction>@toggle:invert</instruction>
<instruction />
<instruction>Prefs SCRIPTDISABLE=EventSaveSelection.js*</instruction>
</function>
</button>