UITextView does not call its marked text methods (setMarkedText, setAttributedMarkedText) for some languages, and does for other languages, but also for the same language it does not call on iOS, but does call on Catalyst (designed for iPad). Here's the example:
class TestView: UITextView {
override func setMarkedText(_ markedText: String?, selectedRange: NSRange) {
super.setMarkedText(markedText, selectedRange: selectedRange) // not called
}
override func setAttributedMarkedText(_ markedText: NSAttributedString?, selectedRange: NSRange) {
super.setAttributedMarkedText(markedText, selectedRange: selectedRange) // not called
}
override func unmarkText() {
super.unmarkText()
}
}
To reproduce:
- Add Polish keyboard to iOS device
- Attach external keyboard
- Run the code and switch to Polish keyboard
- Press and hold letter "A" on keyboard. Character selection menu should appear (see attached video from iPad)
- Using arrow keys on keyboard navigate between selected character
Expected:
for each change, setMarkedText
method is called
Actual result: nothing
The above result is reproducible on iOS, but not on Catalyst (UIKit application run on macOS, in "Designed for iPad" mode). On Catalyst method setMarkedText
is called for each change. Also when run the same code on iPad with external keyboard attached, setMarkedText
is NOT called.
However, this situation is different when select another keyboard: Chinese. For Chinese keyboards, setMarkedText
is called for each change (as I expect)