Fuse Community

TextInput Issue with Cursor when adding text

I have got an Issue with the TextIput.
I want to check the input text and and a “-” when the String’s length == 3.
But when I add the String, the cursor is on the 3. position (“aaa|-”) and not on the 4. (“aaa-|”)

I do it like this:

var textInput = Observable("");
textInput.onValueChanged(module, function(character) {
textInput.value= textInput.value + “-”;

Hope you know what I mean :slight_smile:

No one, who has the same problem? :speak_no_evil::v:t3:

Hello! Have you tried blurring the input, adding the character and then refocusing on it?

No, but could you help me how to archieve this? :slight_smile:

Is there a Javascript function to refocus? :v:t3:
Do you have the same issue? :speak_no_evil:

Sorry, I’ve never had to tackle this issue. I hope someone else could comment on how to focus from JS. I’ve always done it straight from the UX.

Haven’t had the need to move the caret yet but what is the UX way? …cos can just use an Observable and a <WhileTrue> trigger to trigger off UX.

Actualy I dont want to move the caret but I think I have to, because it seems to be a bug…Dont you have the same issue?

I want to achieve a TextInput with a regex in form of : “AAA-AAA-AAA”.
And I tried to add automatically a “-” when the string is length==3. But then the caret moves infromnt of the “-” and not at the end :confused:

Maybe I need to do something else? xD

Maybe you can try separate input fields for the different parts and when they complete a field, you move the focus to the next field?

Sorry for the late reply! And thanks for the workaround! Thats the way I did it now :slight_smile:

But I really want only one Texfield :confused: But does no one else got this Problem? Is there no one who uses paettern/regex ?! x)


I don’t think the issue is with regex; we need to add more caret functionality to TextInput, suggest it in the Wishlist on slack :wink:

1 Like

The caret doesn’t move if you change the content of TextInput not by the system keyboard, that is expected behavior, what we needed just @aeq said are features to set caret position programmatically and other functionality such as text selection, copy and paste.

I am in implementing the Scriptclass method for TextInput for setting a caret position in the javascript. I hope it will be finished this weekend.


Shweet @Ichan_mb :muscle:, yeah, we need all that goodness you just mentioned :laughing:

1 Like