@DTS Engineer ,
Thank you for the earlier response. I understand that Apple’s position is that one cannot programmatically generate a real keystroke event that passes through the OS’s full event pipeline (pressesBegan, etc.). However, based on my experiments, I observe that:
*
OverridinginsertText(_:) / deleteBackward()allow's interception of typed input and the possibility of deciding whether or not to call super so that the text in the text view actually updates.
Calling insertText() programmatically results in the same updating behavior as user typing (for display, selection, etc.)
Given these capabilities, could you clarify:
Is using insertText(_:) / deleteBackward() in a subclass considered an “allowed” way to simulate user text input, for production code (outside of testing)? Or is it officially unsupported / fragile behavior (i.e. subject to change)?
Even though we can’t generate a “real” key press event, since calling insertText(_:) does trigger the same downstream behaviors (delegate calls, text updates, cursor management), is this considered a supported and intended way to simulate user typing in production? Or is it just an internal side-effect that Apple does not want us to rely on?
Topic:
UI Frameworks
SubTopic:
UIKit
Tags: