This should be simple perhaps I am missing it somewhere...
- How can I detect when a user selects / highlights a
UISearchTokencurrently presented in aUISearchTextField?
Here is a photo showing how I am trying to detect when the user selects a token: i.e. the "second" token was selected here
For reference, I am developing this in Swift on iOS 16+.
Upon the user hitting the "return" key, I am adding tokens to the text field:
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
if addTokensOnReturn && !text!.isEmpty {
insertToken(UISearchToken(icon: nil, text: text!), at: tokens.endIndex)
text = ""
return false
}
return false
}
