Type Property 型プロパティ

search

Defines triggers originating from search fields constructed from searchable modifiers.

Declaration 宣言

static let search: SubmitTriggers

Discussion 議論

In the example below, only the search field or search completions placed by the searchable modifier will trigger the view model to submit its current search query.


@StateObject var viewModel = ViewModel()


NavigationView {
    SidebarView()
    DetailView()
}
.searchable(
    text: $viewModel.searchText,
    placement: .sidebar
) {
    SuggestionsView()
}
.onSubmit(of: .search) {
    viewModel.submitCurrentSearchQuery()
}

See Also 参照

Getting Submit Triggers