Hi everyone, I would like to build a Script Add-In that, when selecting a file in one panel, selects that same file in the other panel, if it exists. I have achieved this result, but with a Button Script because I don't know how to capture the selected item in real time. Is there any specific event for this? Any recommendation or help? Thank you!
function OnClick(clickData) {
var lister = clickData.func.sourcetab.lister;
var tabOrigem = lister.activetab;
var tabDestino = lister.desttab;
var painelAtivo = tabOrigem.right ? "Direito" : "Esquerdo";
var pastaPai = tabOrigem.path;
var itemSelec = tabOrigem.selected.count > 0 ? tabOrigem.selected(0).name : "<nenhum>";
DOpus.ClearOutput();
DOpus.Output("Painel ativo: " + painelAtivo);
DOpus.Output("Pasta pai: " + pastaPai);
DOpus.Output("Item selecionado: " + itemSelec);
var cmd = clickData.func.command;
cmd.SetSourceTab(tabDestino);
if (tabOrigem.selected.count == 0) {
cmd.RunCommand("Select NONE");
} else {
cmd.RunCommand('Select PATTERN "' + itemSelec + '" DESELECTNOMATCH MAKEVISIBLE');
}
}
@lxp Are you sure? The OnDoubleClick event seems to be there to react on double-clicking a file or folder, so this could certainly be used? (I did not yet use it myself, I'm just saying it's in the Opus Manual)
Yeah I realize that. I'm just saying: double-clicking a file seems a bit more close to the comfort that this person was looking for, than clicking once on the file and then click in another place on some button.
In that case, how would you trigger the action that is usually bound to double click (e.g. launching the program associated with this file type to open it or execute the file ...). That will lead to an odd behavior IMHO.
If it leads to "an odd behavior" that cannot be prevented, then it would seem to me that the OnDoubleClick event either makes little sense or isn't implemented very well.
By the way isn't it also "odd" that we don't have an OnSingleClick (or perhaps more aptly called 'OnFileFolderClick') event? Or maybe the existing OnClick event - adapted to react (differently) to the single click on a file, rather than on a button.
I don't see that as an implementation issue.
The OnDoubleClick event lets you intercept a double click to either:
Insert an action before the standard one
Replace the standard action
Make some kind of control to decide wether you go on with standard action
Sounds good to me.
The problem here is what you want to do with the double click, which is to use it as a substitute to identify a selection.
If you replace the standard action, it's becoming a bit convolutive to trigger the standard action (you'd need to revert to right-click, etc ...). If you don't replace, then in order to identify selection you will "execute" the file (or open it in its default editor).
I agree a OnSingleClick or an OnSelect could be interesting. Note that they are two different things since you can select file in other ways than clicking on them (at least: 'lasso" selection of multiple files/folders, use of Select command).
It was just a suggestion. Maybe the person who asked the question prefers this use of doubleclick over the standard ones. Maybe it can also be limited to a combination with pushing the Shift key, or anything of the sort. I don't now.
Talking about 'lasso selection' (I'm deviating) - did you never miss the possibility to activate a small zone at the left margin of the lister - let's say just a few millimeters - where you can start a lasso selection? I had the same problem in Windows Explorer (ages ago when I wasn't using Opus) but Opus has that too: when the lister screen is filled, I can't start this famous lasso - unless I maximize the Opus window for the occasion). If I could activate an option to have a tiny vertical click-free (but not mouse-free) zone on the left, I would certainly use it.
@lxp, you cleared up a major doubt I had. I had already searched through the Opus manual for any related event and couldn't find anything, but I wanted to confirm it with someone as experienced as you. I'll give WatchTab() a try. I'm already somewhat familiar with it since @errante recommended it to me when I was building Info Bar. Thank you very much.
@Bennjamin, OnDoubleClick isn't a good option because it would cause folders to be entered or files to be opened, and that's not the goal. The goal is simply to select files in one panel and visually link them to their counterparts in the other panel. Thanks a lot for the discussion and for your willingness to help.
@PassThePeas, thank you as well. As always, your excellent logic and willingness to help are greatly appreciated.
@Jon Thanks. I think I noticed that option in the past and I think I clicked it on and off a couple of times, not understanding its function (after all, it does not make appear any sort of subtle but visible area, suggesting its specific function for lasso-selection).
I still didn't get it at first, because I had my eyes on the column headers and I just saw a bit of a shifting, but the name in the first column simply remains in place - I saw no explicit indication that a special area has been aded, the area didn't stand out.
EDIT: I've now understood this is because I had adapted the default background color for all columns, giving them a light gray. Once I had reset the "unselected background" color to the original black, the lasso-selection area on the left suddenly became visible.