Post

Replies

Boosts

Views

Activity

Focusing the initial item in a collection view in Catalyst on macOS
I have a Catalyst app running on macOS Big Sur where I need to select and focus the first item in a collection view. By default a programmatically-selected item is only selected, not focused. From what I understand, Catalyst uses the Focus Engine from tvOS to manage focus, and therefore applying the same concepts here should achieve the same result. However, I've had zero luck getting this working. Things I have tried... Overriding preferredFocusEnvironments on the view controller and returning the collection view, and implementing indexPathForPreferredFocusedView(in: in the collection view delegate. This works in so much as both methods are called, but has no effect on the outcome. Overriding preferredFocusEnvironments and directly returning the currently selected cell from the collection view. Overriding preferredFocusEnvironments and returning the cell at a hardcoded index path, for instance IndexPath(item: 0, section: 0). Unfortunately, none of these approaches has the desired outcome of actually focusing the selected item. Can anyone advise on how to achieve this?
0
0
745
Jul ’20