iPad SwiftUI TextField data editing by user

XCode 14.3 developing for iPad app targeting iOS 15.0 +. Using SwiftUI, Combine, Vision, VisionKit

Situation: I have a SwiftUI TextField that I preload with a string (say, 12 characters for this discussion).

Desired Behavior: The user wants to tap into the string, add or delete a character within the string, then save it. For example, I display 1234*6789012 and he wants to replace the asterisk with the digit 5. Simple, simple, something text fields have been handling for decades.

Undesired Behavior: At this time when the user tries to tap into the field, the SwiftUI TextField prevents it. It positions his edit location at the end of the string and gives him a "Select | Select All" option. If he clicks Select it gets even worse --- it then gives him multiple new options. I need to eliminate that complexity and simplify the data entry process.

Requests for Assistance: This complex set of popup options for a SwiftUI TextField looks like a property setting at work. What is it, where can I find it documented, and how do I un-set it? Alternately, what magic google string of keywords can help me locate that property?

Next, isn't there another (and simple) property that I can tell TextField to accept his finger tap, position into the string wherever he tapped, and let him insert / backspace / etc as needed?

If this requires another code module(s) or delegates and objects and geometryReaders etc to allow that simple user behavior, please provide a link to whatever document fully details that code. I am slow, so please be patient in your explanation. I am very slowly getting used to the idea that simple behavior in Swift can sometimes require lots of breakable code behind the scenes. And that a detailed explanation on the web written two+ years ago is no longer relevant because the Swift product has gone through several major changes in direction since that detailed explanation was written.

Current Settings for the TextField:

  • .limitTextLength(etc etc - a custom function to replace the "maxlength" property of most text fields out there)
  • .onChange ( this calls a string.uppercase() function to replace the "All Caps" property of some text fields out there. Then it calls a removeNonAlphaNonNumeric() function to remove anything not 0-9 or A-Z since the keyboard allows numerous undesired special characters.
  • .disableAutocorrection(true)
  • .textCase(.uppercase) -- intended to force uppercase, but the user can override it easily or accidentally
  • .textInputAutocapitalization(.characters) --- another attempt to force uppercase
  • .keyboardType(.alphabet)
  • --- this is followed by properties setting the font, bold, frame width, padding, border etc.

Thanks for your assists, folks! Every suggestion is appreciated.

iPad SwiftUI TextField data editing by user
 
 
Q