TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Toggle isSearching Binding variable in searchable with a keyboard shortcut

Forums > SwiftUI

Currently, we can add a search field to any list with searchable:

searchable(text: $searchText, isPresented: $isPresented, prompt: "placeholder text")

Is there anyway to toggle $isPresented with keyboard shortcut ⌘+F ? I tried adding an invisible button, but it doesn't seem to work right because dismissing the search interface doesn't seem to toggle isPresented. Developer documentation isn't very helpful — they don't seem to have thought of this use case?

2      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.