After toggling flatview the selected item is offscreen

If I toggle the flatview using Set FLATVIEW=Toggle,Mixed the currently selected file is moved outside of the viewport. You can see on the screenshot that the first folder will get the focus but the file is still selected. How can I bring the focus back to the selected file to make it visible after turning on flatview?

I tested to append Select {file} MAKEVISIBLE DESELECTNOMATCH but this doesn't work since all other files having the same name are also selected.






Does anybody have an idea how I can select the proper file (and bring it back on the screen) after enabling flatview?

I don't think its possible, well perhaps with a script.
The Set FLATVIEW=Toggle,Mixed does two things, it moves your selected item off the screen, it also changes the item that has the focus. If you have two items with the same name as you have noted Select {file} MAKEVISIBLE DESELECTNOMATCH will match them all. You can get the full file path using {filepath} but the Selectcommand wont accept a full path. If you could stop the Set FLATVIEW from changing the focus then you could use Select THIS to make it visible.

Since the selected item is kept we need a command that simply bring the focus back from the top of the list down to the first selected item. I am not sure if there is such a command.

On the other hand I just verified that other content changing actions (e.g. quickfilter) actually maintain the focus and the selection to keep correct (previously selected) item. Thus I guess it would be the best if this would be solved programmatically after the flatview is enabled. I think this would help much because after enabling flatview you probably have a lot of items on the screen, so that it is time costly to find the last selected item manually (if needed).

Leo, is there any command that does the inverse thing of Select THIS. I want to move the focus to the selection instead of the selection to the focus.

We are going to treat this as a bug, and fix it so that the focus item is preserved if possible and kept in view when the flat view mode is changed.

That's great thanks Jon.

I hope you guys don't mind me asking here, but I think it is somehow related to this topic:

Does the fix also affect visibility of selected items when switching from details to thumbnails and back?
That's mainly where I miss the "keep visible" thingie.

Thanks! o)

Hey tbone, I don't think it will. This will stop the focus from changing.
To make the file visible you can use this command Select THIS. Just beware this will select the focus item and then make it visible. So in effect it will clear your current selection (if its not just the item that has focus).

So I think, to keep the selected items in reach, I'd need to:

  • internally save the selection
  • switch view mode
  • set focus to the first file of the "saved" selection
  • visibly select the files
  • and finally call "SELECT THIS"

But is there a way to set the focus by script? The other steps seem doable and easy to realize.

Thank you! o)

It sounds like its getting rather complicated, I'm not sure this is a candidate for a script. It is a rather common request, and difficult to get the logic correct with the current available commands.

I think what is needed is:
[ul]
[li]Show FocusedItem - Make the current item that has the focus visible[/li]
[li]Show FirstSelectedItem - Make the first selected item visiable[/li]
[li]Set VIEW=[name] KeepFocusItemVisible - When changing the view, keep the focused item visible.[/li][/ul]

Thanks for your help and inspiration wow! o) It seems I got around making it too complicated, as this little script command does the trick.

It mainly deselects all files and then reselect them with the "MAKEVISIBLE" switch. Works like a charm here!

Btw: ReSelecting the files by the script one by one was very slow, you could sit and watch DO doing it, so it had to happen in one go by passing the collection at once.
The most difficult part then was to remember the name of that switch "FROMSCRIPT", which is not documented online, but the forum revealed it finally.

Thanks all, another leap forward to perfection! o)

Nice solution mate, didn't know about the FROMSCRIPT switch. Good stuff.

Correction: The switch is documented online! I guess I overlooked it, because I was looking for "FROMCOLLECTION" or something at first.
What's for sure is, I'm overtired, so please excuse! o)

@wow
Yes, these little switches and things you cannot get together too often!
But once in a while you remember that there was something you read about some weeks ago in the forums. So let's keep it up! o)

:thumbsup: Thank you very much!

What's about the idea of having a command to (1) make the currently focussed item visible and (2) to select the currently focussed item.

Works very well for most commands, but the flatview seems to do something different. The command given below doesn't move the viewport as expected. I guess we have to wait for Jon to do the announced changes.

Set FLATVIEW=Toggle,MixedNoFolders
ScrollSelectionIntoView

I would say it works quite "ok" for me in flatview. It has trouble selecting directories in "grouped" mode it seems, but with files and the rest of the flatview-stuff, it looks ok to me. I tested and created a button with the code you listed, maybe it's your DO version coming into play here? I'm on v11.4.

That "ScrollSelectionIntoView" does not touch the focus/cursor btw, just in case we are talking about different things. o)

Directory Opus 11.4.5 (beta)

Looks like your request has been answered.
Nice one thanks for the update Dev's.