Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
(This is a follow-up to JDK-8077916.) javafx.scene.control.skin.TextAreaSkin.TextPosInfo needs to be changed to take character clusters into account, as noted in JDK-8092327, point 2. As it currently stands, TextPosInfo#getInsertionIndex() is broken: it may return an index inside a character cluster. Indeed, the skins themselves don't use TextPosInfo#getInsertionIndex(), but rather Utils#getHitInsertionIndex(TextPosInfo hit, String text), which is not available to the users, since Utils is in com.sun.javafx.scene.control.skin. Also note that Utils#getHitInsertionIndex in order to work around the limitation of TextPosInfo, needs to see the text again. I think the right thing to do is to make sure the returned TextPosInfo is correct, otherwise it is useless for anything but private implementation again. The most reasonable place to fix this seems to be to fix the hit test implementation on Text, rather than keep it broken and then work around it in text input controls. With that, it would also make more sense to put this class in the javafx.scene.text package. Also note that the current version of TextPosInfo API is good for positioning caret, but not for getting the character under the cursor (JDK-8091012), which is useful e.g. for displaying a tooltip based on the word under the cursor. As I suggested in JDK-8136350, I think a reasonable API for TextPosInfo would be public OptionalInt getCharacterIndex(); public int getInsertionIndex(); Note the OptionalInt, to determine whether any character was hit at all.
|