How to select a ProjectItem from code ? (or avoid focus to move when a bin is created)

The code I’m working with is creating a new Folder.
Somehow this move the focus to this newly created item.

This is disturbing the user flow (and/or further automated command).

I need to either reset the focus to what was selected before the move (I could cache the active Selection with ProjectItemSelection::getItems but that object has no “setItems”) or, better, prevent the section to move to that newly created Bin (but I did not found any option for that)

Is there a way to do this ? or not available yet ?

1 Like

I think there is no function to set a ProjectItem (or FolderItem) as selected. The only workaround I can think about right now would be to just create another folder at the end and delete it again so nothing becomes selected in the Project View. If the folder has the same name and is in the same subfolder as the previously selected item, the focus might even be at the same location, the items are just not selected anymore.

Yeah, that won’t quite solve the issue.

If an item is selected before the Bin creation, no workaround seem to revert back to what is was before. Especially if more than one item was selected to start with.
( I originally considered saving the selected item before the bin creation then run 2 “rename” Action ”foo” → “foo1“ → “foo”, but that is an ugly hack and won’t work for multiselect anyway)

This is not blocking per say - but annoying as it may require the user to re-selected the (previously selected) items once the action is complete.