I have a custom view in SwiftUI that I wish to accept and respond to keyboard input for. My current approach involves adding a TextField to manage the keyboard and responding to activity via onReceive(), which is functional. However, I really don’t want the TextField to be visible and I would like tapping on my custom view to display the keyboard (ie. set focus to the TextField). Any suggestions?
Hi @vincemarco, welcome to the forum community! What about trying to use the UIKeyInput protocol and implementing becomeFirstResponder with the view you have? I have not tried this myself but it is a suggestion that might be worth trying.
I think you cannot make the textField the first responder easily. The way to achieve that would be to bridge to UIKit and use a native control.