Post

Replies

Boosts

Views

Activity

Issues with Scribble on a custom UITextInput view
Hi, I have a custom UITextInput view implementing all the methods (I guess) of UITextInput. I'm also using a custom UITextInputStringTokenizer subclass, but the issue it the same with a bare UITextInputStringTokenizer: whatever I'm trying to select, the interaction selects the whole sentence, or some sub-sentence, but never the word. The same if I strike through, or try to insert or delete a space. I'm seeing the tokenizer being asked for sentences ranges, but never words. In an off the shelf UITextView, I'm seeing the same ranges being asked, and then a convergence with requests for words ranges. It never happens in my view. I'm quite sure the "positions for point" that I'm returning are correct, as well as the tokenizer's responses. If I'm using my finger, everything is fine. In other words, scribble interaction fails to identify the range to act on, and always find a range that is bigger than it should be. If I draw slowly to the right, sometime I see the selection handle position move ~5cm farther than the pencil to the right. If draw slowly to the left, the same, with the handle ~5cm farther to the left. Does anyone has the same issue? This renders scribble unusable in my view. This is for iOS 14 beta 1 on a 10.5 iPad Pro with the 1st generation Pencil. The issue happens whereas I'm installing myself an UIScribbleInteraction or do nothing and let the system do this itself on UITextInput apparently. Thanks in advance. Thomas
1
0
585
Jul ’20
Meaning of Offset in UITextInput
Hi, I have doubts on the meaning of offset in various methods of UITextInput. As a convention, let call "utf" offset the value returned by utf16offset of String and "character" the offset corresponding to the visible Character. Thus, between the start and end of "👨‍👩‍👧‍👦", there are 1 character position and 11 utf positions. For the method position(from position: UITextPosition, offset: Int) -> UITextPosition?, it seems that offset means characters: the text input will call this method with offset = -1 when deleting backward and we have to return the whole emoji range for example. Otherwise, we will return an invalid position "inside" the emoji and break it appart. The -1 seems to come from the text input system and I didn't find any call to other methods to generate it. For the method func offset(from: UITextPosition, to toPosition: UITextPosition) -> Int, the documentation states "Return the number of UTF-16 characters between one text position and another text position." So that's utf offset and we must return 11 for the emoji. This seems confirmed by UIStringTextInputTokenizer which uses this method to mesure things and will return wrong results if one returns characters offsets. This bothers me however because it really seems that both functions are reciprocal, and the distinction for the meaning of offset only comes from experiences at runtime. Can someone confirm that offsets have indeed different meanings in both functions? Thank you!
2
0
519
Jun ’20