Howto: create hotkey that switches to tree

I'm trying to create a hotkey which, when pressed in a lister, will shift focus to the directory tree (with the current directory selected). However, I'm having trouble finding the appropriate command to do so (I look through the "Go" options but didn't manage to find the appropriate item). What command can I use to accomplish this in a hotkey?

Set FOCUS=Tree

Thanks!

Set FOCUS=Tree works great! One caveat though: If the tree is scrolled up or down, such that the current folder is not shown within the visible area of the window, then this remains so after executing "Set FOCUS=Tree"; that is, the selection remains off the screen, and is not visible. Is there any way to instruct the tree to center the selected directory within the visible area?

Not via a command, or at least not via one which works when also changing the tree's focus.

Maybe something like:

Go REFRESH=source
Set FOCUS=Tree

...?

Nice one, that seems to work here.

Steje - thanks so much for this excellent code sequence!

I made one small adjustment. Although "Go REFRESH=source" does effectively reposition the tree selection to the center, it also resets the lister. So if the lister had been scrolled down, or if certain files were selected, that would all be lost; the lister is scrolled back up to the top, and selection is reset. Instead, I used "Go REFRESH=tree", which recenters the tree without affecting the current lister.

In sum, then, my hotkey's definition now looks like this:

Go REFRESH=tree
Set FOCUS=Tree

Upon hitting the hotkey, focus is transferred to the tree, where the current directory is selected and centered within the display.

Thanks Leo and Steje for all your expert advice on this matter.

Ah, yeah that makes much more sense... I didn't even remember that there was a 'tree' arg for refresh. Glad you caught it and used it to make it better for yourself!

Hi, I want to do this same thing and found this old thread, but the function is not working for me in DO 12.17. Do I need to modify the function/definition?

A forum upgrade a couple of years ago broke the code tags on old posts. The function should be on two lines:

Go REFRESH=tree
Set FOCUS=Tree

Thanks, it's working now.