Same issue here, trying to implement Cmd+F keyboard shortcut for starting the search on a macOS app.
@colalo For iPadOS or Catalyst there seems to be an workaround based on SwiftUI-Introspect, see this answer on SO:
https://stackoverflow.com/a/69308041/3451975
But for macOS, there's currently no solution. It would be great if the @Environment(\.isSearching) would be settable, then I could write a hidden button like this:
Button("Search") { isSearching = true }.keyboardShortcut("F").hidden()
Alternatively, the searchable() modifier could return a specific type (not some View) that supports keyboardShortcut, then the code would look something like this:
myView.searchable(text: $searchText).keyboardShortcut("F")
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: