I'm curious on how does SwiftUI applies some of the available view modifiers like keyboardShortcut
, which can be applied to any View but it will only work on the first Button child it finds down the view hierarchy:
The target of a keyboard shortcut is resolved in a leading-to-trailing, depth-first traversal of one or more view hierarchies. [...] If multiple controls are associated with the same shortcut, the first one found is used.
Or same thing with .navigationTitle
, which apparently you can place anywhere in the view hierarchy and it will be picked up by the next NavigationView
, but how? I mean, how can i do this in SwiftUI by myself?
It would be awesome to just place some random view modifier which does this magic things to some items down the view hierarchy.