Ok, so I know Apple's UITextInput
protocol requires the two UITextRange
properties selectedTextRange
and markedTextRange
and the documentation says that selectedTextRange
is a subrange of markedTextRange
which is an uncomfirmed text range by the user yatta yatta. That still doesn't make some things clear to me regarding how I ought to implement the two text ranges differently. Could someone visually explain to me the difference between selectedTextRange
and markedTextRange
? I know that when the length
of selectedTextRange
is 0
it indicates a blinking caret at selectedTextRange
's location
. But what the heck is "marked text"?? I've only seen the following for text views in iOS:
Which I assume represents the current selectedTextRange
. What does markedTextRange
look like? Or is it basically the exact same thing? I'm so confused :( Thanks in advance for any help! The documentation has proven itself useless in my understanding of how to implement the UITextInput
protocol.
EDIT
Does implementing markedTextRange
have anything to do with the fact that some text in a view could be "markable" but "readonly" and selectedTextRange
indicates the subrange in the "marked text", markedTextRange
, that is readwrite?
-(BOOL)textField:(UITextField*)tf shouldChangeCharactersInRange:(NSRange)r replacementString:(NSString*)s {return [tf.text stringByReplacingCharactersInRange:r withString:s].length <= 3;}
This can be reproduced onJapanese - Romaji
keyboard – Formal