Determining item selection status in a standalone viewer?

I had hoped to be able to test the selected status of each image in a standalone viewer's collection of Item objects but the sample code returns zero no matter how many of the images are (or were) actually selected. The selected property always returns false.

var vwr = DOpus.viewers.lastactive;
var item_count = 0;
for (var i = 0; i < vwr.files.count; i++) item_count = item_count + vwr.files(i).selected;

Is this because the tab from which the viewer was launched may no longer be open? It would still be useful to know if only one item was originally selected.

You could ask the folder tab which files are selected in it, if it is still open. The viewer object has a reference to the folder tab that launched the viewer, when applicable.

Selection state doesn't make sense or apply to the viewer's list of files (the files it will cycle through when you go to the next/previous image). That list may not (usually will not) be the same as the list of files in the viewer's Marked pane either.