Inspired by this thread, I want to display some properties of the selected item to the Status Bar via script.
Show Display and Hide filters in the Status Bar - Help & Support - Directory Opus Resource Centre (dopus.com)
I checked this script again: The dialog becomes visible when switching tabs:
Can I make the Viewer Panel Open/Close, when a media file is Selected/Deselected? - Help & Support - Directory Opus Resource Centre (dopus.com)
If I set to User defined command:
//Function : Viewer panel Auto Open Close
//Modified : 2022-11-09
//Version : 1.1
//(Source: https://resource.dopus.com/t/can-i-make-the-viewer-panel-open-close-when-a-media-file-is-selected-deselected/42698/11)
function OnClick(clickData)
{
var tab = clickData.func.sourcetab;
var cmd = clickData.func.command;
var dlg = clickData.func.Dlg;
if(!DOpus.Vars.Exists("ViewerAutoOpenClose")) //(if the variable does not exist, then)
{
DOpus.Vars.Set("ViewerAutoOpenClose") = 1; //Set the variable
//if(DOpus.listers.lastactive.viewpane == 0) {cmd.RunCommand("Set VIEWPANE=on");} //Open if the viewer pane is closed
} else { //Else, if the variable exists, then
//DOpus.Vars.Delete("ViewerAutoOpenClose"); //Delete variable to end the script
if(DOpus.listers.lastactive.viewpane == 1) {cmd.RunCommand("Set VIEWPANE=off");} //Close if the viewer is open
}
dlg.detach = true;
dlg.template = "dialog1";
dlg.title = "OnSelect";
dlg.create();
dlg.show();
dlg.watchtab(tab, "select");
var msg;
do
{
msg = dlg.GetMsg();
if(!DOpus.Vars.Exists("ViewerAutoOpenClose")) //If the variable does not exist, then
{
if(DOpus.listers.lastactive.viewpane == 1) {cmd.RunCommand("Set VIEWPANE=off");} //If the viewer pane is open, close the viewer pane
break; //End the script
}
if (!msg.result)
break;
var event = msg.event; //Get event
//var control = msg.control;
var value = msg.value;
//Log("Event: " + event + ", Control: " + control + ", Value: " + value);
if(event == "tab" && value == "select") //If there is a selection event
{
tab.Update(); //Update
if(tab.selstats.selfiles > 0) //If the selected file > 0
{
var item = tab.selected_files(0); //Get the first file selected
if(item.metadata == "image" || item.metadata == "video") //If it is an image or video, then
{
if(DOpus.listers.lastactive.viewpane == 0) //Open if the viewer pane is closed
{
cmd.RunCommand("Set VIEWPANE=on");
}
} else {cmd.RunCommand("Set VIEWPANE=off");} //If it is not an image or video, close the viewer panel
}
else if(tab.selstats.selfiles == 0 && DOpus.listers.lastactive.viewpane == 1 || msg == 0) //Closes the viewer panel if no file is selected and the viewer pane is open
{
cmd.RunCommand("Set VIEWPANE=off");
}
}
}
while(msg);
}
/*
function Log(msg, e)
{
DOpus.output(String(msg), e || false);
}
*/
==SCRIPT RESOURCES
<resources>
<resource name="dialog1" type="dialog">
<dialog fontsize="8" height="14" lang="english" opacity="0" width="54">
<control close="0" height="14" name="button1" title="Exit" type="button" width="54" x="0" y="0" />
</dialog>
</resource>
</resources>
And run the User defined command via OnActivateTab event, the dialog is always invisible:
// ViewerAutoOpenClose
// (c) 2022 Ken
// This is a script for Directory Opus.
// See https://www.gpsoft.com.au/DScripts/redirect.asp?page=scripts for development information.
// Called by Directory Opus to initialize the script
function OnInit(initData)
{
initData.name = "ViewerAutoOpenClose";
initData.version = "1.0";
initData.copyright = "(c) 2022 Ken";
// initData.url = "https://resource.dopus.com/c/buttons-scripts/16";
initData.desc = "";
initData.default_enable = true;
initData.min_version = "12.0";
}
// Called when a tab is activated
function OnActivateTab(activateTabData)
{
var cmd = DOpus.Create().Command();
cmd.RunCommand('ViewerAutoOpenClose')
}
// Called after a new folder is read in a tab
function OnAfterFolderChange(afterFolderChangeData)
{
var cmd = DOpus.Create().Command();
cmd.RunCommand('ViewerAutoOpenClose')
}
Is it possible to make the custom dialog always invisible without splitting the script?