Viewer pane isn't updated when switching tabs

@aka
Try this. Not too bad I think, but it's surely not enough to cover all situations. The viewerpane following each tab and source/dest change actually makes clicking around a nervous experience. But maybe that's something one can get used to. I guess for specific filetypes that trigger a heavy plugin in the viewerpane (like a movie player), this may lead to noticeably delays as well. The pane won't be updated whenever only folders or multiple files are selected. So it will be out of sync still for tabs, that don't have a something selected (showing something from the active tab before). You cannot clear the pane without getting really messy and hacky.
Event.GUI_SyncViewerPane.js.txt (3.47 KB)

[quote="tbone"]
I guess for specific filetypes that trigger a heavy plugin in the viewerpane (like a movie player), this may lead to noticeably delays as well. [/quote]

I must say you've done me a lot of happiness for this weekend. This script is awesome! Personally I forgot about the existence of Select THIS which can be effectivily used to achieve exactly what we have on place one of our wishlist. Tbone, thank you very very much!!!

Actually we only have the text and image plugin enabled. All other files (audio, video, docs, etc.) have to be opened in their separate applications. Thus the textviewer plugin is the always enabled most important plugin in our configuration.

Now I'm starting to hope that Jon and Leo realize the missing URL support to the text viewer and maybe some line numbers in the first column. This has been on place two of our wishlist for more than 10 years (thanks tbone now it's on 1st place) :wink:.

I just have a look to my first version after you push the idea of Select THIS to me. Initially I tried to reselect all items but that doesn't affects the viewer pane as expected. Now I add the magic line to even handle selections where the focussed item is not part of the selection.

Maybe you want to give that a try ...

function OnInit(data){
	data.name = "Viewer Pane Follows Focus";
	data.desc = "Automatically updates the viewer pane on focus changes (e.g. switching tabs).";
	data.copyright = "(C) 2015 AKA-Mythos"
	data.version = "1.0";
	data.default_enable = true;
}

function updateViewerPane(tab) {
	if (tab.source) {
		var cmd = DOpus.Create().Command();
		cmd.AddLine("Select THIS"); // thanks to tbone
		cmd.AddLine("Select FROMSCRIPT DESELECTNOMATCH");
		cmd.addFiles(tab.selected);
		cmd.Run();
	}
}

function OnActivateTab(data){
	updateViewerPane(data.newtab);
}

function OnSourceDestChange(data){
	updateViewerPane(data.tab);
}

Unfortunately this script leads to a noticable flickering (due to the deselection / reselection operations). It would be much smoother if we can control the focus (which controls the viewer pane) independent of the selection (which controls the focus) by certain options for the Select command.

Select SETFOCUS for that. (Requires a reasonably recent version of Opus.)

We want to refresh the viewer pane but keep the selected and focussed item (which may not be the same). But I do not understand how the focus can be re-set to the currently focussed element by Select SETFOCUS. Therefore I hoped that Select SETFOCUS THIS would do that, but it doesn't.

Would it be possible to introduce an option that simply updates the currently focussed item in order to update all lister panels around?

Select SETFOCUS=update

Or even more intuitive:

Select SETFOCUS=this

:thumbsup:

By "intuitive" I'd understand something like this:

var item = tab.focus; //get item that has the focus DOPus.ViewerPane.Show(item); //update the pane
Any additional switches on the select command like MAKEVISIBLE, SETFOCUS, SHOWFOCUS, EXAKT, FROMSCRIPT and THIS should be prevented. I struggle already while keeping them apart and understanding their exact differences. The manual helps, but this is not getting any better with another switch. o)

Both of your proposed methods seems to make pretty much sense in many other situations (... and obviously that would fix this issue very effectively) :slight_smile:

To be honest I am frustrated now, because I spend nearly the whole day in hacking around this problem and finally it still doesn't work smoothly. Currently I do not know if there is something left what I can try next.

[quote="leo"][*]This is by-design (although not set in stone). The viewer loads a file when you click on the file (or push space when the file has the focus). If you then change tabs, the viewer doesn't do anything, unless you click on a file in the new tab.

This can be important when dealing with files that will take a long time for the viewer to load, as it would get in the way of quickly changing from one tab to another and then back.[/quote]

I guess that file navigation occurs much more often than tab switching. What I want to say is that most users probably would perform much more file selections (which DOpus can smoothly handle even at high frequencies) than tab switches. Thus I don't think that viewer pane updates would get in the way of quickly changing from one tab to another. But anyway there could be such a fancy checkbox. :slight_smile:

If I understand everything correct you guys try to provide a solution for a feature request I have done a long time ago.

Can anyone of you explain me how I can try out these scripts? I do not know where the script code has to be pasted...!?

Navigation happens by clicking on folders, which (at least currently) has no effect on the viewer.

Download my uploaded *.js.txt file or copy and paste AKAs version into a new file with *.js ending, then use DO and enter
"/dopusdata/script addins" into the path-bar, a location opens where you need to put these file(s). For scripts in general, there is a prefs section here: "Preferences -> Toolbars -> Scripts". Sometimes a script needs to be enabled there before it will have an effect or requires some configuration beforehand (there is a config button visible for each, once a script has been selected from the list). The examples here, do not feature any configuration items yet.

Take your time and see here for more scripts on various topics:

https://resource.dopus.com/c/downloads/script-buttons-add-ins

@AKA
Don't be frustrated. Just start a another script, there are even more pitfalls to reveal, talk about and fix! o)

Sorry, I meant file navigation by pressing cursor up/down to quickly iterate over the file-list upwards or downwards. This leads to hight frequent updates which are handled very well by the viewer pane. I don't think that there is a performance problem. Anyway I would be happy if this feature request was moved from stone to sand... :slight_smile:

[quote="tbone"]By "intuitive" I'd understand something like this:

var item = tab.focus; //get item that has the focus DOPus.ViewerPane.Show(item); //update the pane
[/quote]

To have a tab.focus property would help a lot and I definitely vote for that as much as I can! :slight_smile:

But instead of introducing DOPus.ViewerPane.Show(item) it would be even nice to have this as a command argument instead!

Like this ...

Show foobar.jpg VIEWERPANE

Me too, but since it seems to be a far-reaching change maybe it's more likely that Jon and Leo decides to introduce two new commands that will enable us to do that by ourself. :thumbsup:

To achieve the same effect by a script we need tbones command proposal to be realized and one fix for out-of-order event handling ...

I've merged the two viewer pane threads, since they both were both about the same thing and resurrected at the same time, and it looked like we were going to have similar ideas posted into both threads.

This kind of related (and following on from Leo's earlier comment about not immediately updating the viewer pane when switching tabs)

Is it possible to have the viewer pane tied/linked to particular tabs (appearing/disappearing if a particular tab is selected)?

Use case: I have a folder of text files and a folder video files, each displayed in a different tab.
I need to alternately select & view contents of various text files (with the viewer pane open), and double-click some of the video files to run them in an external player (ideally, with the video pane closed).

Currently (Dopus 10.x) if I switch from the "text files" tab to the "video files" tab and double-click a video file, it opens both in the viewer pane and the external player. The current behaviour would be ok, except quicktime takes an aeon to start up in the viewer pane.

Apologies if this is too off-topic for the thread, happy to start another if necessary.