I'm trying to assign the same shortcut to two functions, one should run only when folder(s) are selected, and the other should run only when file(s) are selected (ok to limit the test to the first selected item to avoid the issue of mixed selection).
I've found that a rename command has such on TYPE
option, however, I couldn't find a way to replicate such a condition for an arbitrary command (didn't find whether the built-in @if
condition is capable of such a test)
How would I do that?
Thanks
What are the commands?
I'd like Ctrl+Enter to open folders in new tabs and files in an external text editor, so it's a combination of two commands
Go FROMSEL NEWTAB
"/path/to/editor.exe" {allfilepath}
A small script is the way to go for that:
function OnClick(clickData)
{
var cmd = clickData.func.command;
var dirCount = clickData.func.sourcetab.selected_dirs.count;
var fileCount = clickData.func.sourcetab.selected_files.count;
if (dirCount > 0 && fileCount == 0)
{
cmd.RunCommand("Go FROMSEL NEWTAB");
}
else if (dirCount == 0 && fileCount > 0)
{
cmd.RunCommand("\"C:\\Program Files\\TextPad 7\\TextPad.exe\" {allfilepath}");
}
else
{
cmd.deselect = false; // Leave things selected if nothing happens.
}
}
Here is the button in a .dcf file to make things easier:
New Button.dcf (1.3 KB)
To add a button from a .dcf file to your toolbar:
- Navigate to where the .dcf file is. (If it is inside a zip, extract it first.)
- Select Settings -> Customize Toolbars.
- Drag the .dcf file to your toolbar.
- Click OK in the Customize window.
It works, thank you!