TextField: position the cursor on a first click, without "select all"

Hello,

I need to position the cursor in TextField on a first click, without “select all”.

I tried to do it via RegisterCallback, but I don’t have an appropriate way to get the text index position from the mouse position.

I’ve found similar things in the TextEditor, but it’s private to TextInput. I could access it via child element, but maybe I miss something?

Thanks

1 Like

Hi, you can use TextField.SelectRange(startIndex, endIndex); to set the cursor position.

This is not particularly intuitive to set the cursor position, so perhaps we should add an helper method to help with this case.

1 Like

Thank you for the reply, I tried SelectRange, but I didn’t get a convenient way to convert mouse position to cursor position.

ITextInputField.editorEngine has everything I wanted: I could achieve slightly different behavior of TextEditor on mouse & keyboard hotkeys. But it’s is internal. I hope you will add it to public API to some extent.

1 Like

FYI we now have public APIs for customizing this behavior: first and second properties.

Sorry for necroing this post, but this comes up in search engines.