I want to set the marked text programmatically and since iOS5 UITextView and UITextField conform to UITextInput this should be possible but for some reason I always get the markedText
to be nil. :(
What am I missing here?
This is what I've tried without success:
(While the textview is firstResponder)
1.- When the text view contains no text:
text: "", selectedRange : {0,0}, markedText: nil.
[_textView setMarkedText:@"月" selectedRange:NSMakeRange(0, 1)];
Result: text : "", selectedRange: {0,0}, markedText: nil. (Nothing changed)
2.- When the text view contains text + some marked text:
text : "AAA", selectedRange = {0,3}, marked text at the end : "太陽" then I do:
[_textView setMarkedText:@"地" selectedRange:NSMakeRange(0,3)];
Result : text :"AAA", selectedRange: {0,3}, markedText: nil; (the marked text became nil)
In both cases is like setMarkedText:selectedRange:
would be setting the current marked text (if some) to nil.
Any help would be highly appreciated :)
UPDATE
Since the concept of marked text seems to be unclear, here is an explanation:
In multi stage input languages (e.g. Japanese) you can input regular text (like english) or input marked text (like japanese).
Here I wrote regular text : regular text
then I wrote marked text つ
and then I wrote marked text き
so it was appended becoming つき
.
Marked text (text in the blue box) represents a transitional or intermediate input stage because it can become into other characters/words called candidates. Candidates are shown in the big box.
This screenshot was taken when using a bluetooth keyboard in the iPad but you will get similar results when using the software keyboard when writing japanese for example.
Before writing つ
the textview was:
textView.text : "regular text"
textView.selectedRange : {12,0}
textView.markedText:nil
Then I wrote つ
and the text view became:
textView.text : "regular textつ"
textView.selectedRange : {13,0}
textView.markedText: "つ"
Then I wrote き
and the text view became:
textView.text : "regular textつき"
textView.selectedRange : {14,0}
textView.markedText: "つき"
Which is the current state of the text view.
I want to be able to set the marked text programatically :)
Is this possible? -- According to UITextInput docs it is.