How to automatically switch from one LineEdit to another?

Godot Version




I am trying to make it so that whenever user types 1 letter in LineEdit (Max they can type is 1 character) they automatically switch to write in the LineEdit next to it.

Any ideas how I might be able to achieve this?


Id use this signal

text_change_rejected ( String rejected_substring )

Emitted when appending text that overflows the max_length. The appended text is truncated to fit max_length, and the part that couldn’t fit is passed as the rejected_substring argument.

then when it fires you know they’ve exceeded the one-character limit and you can then switch focus to the next lineedit.

1 Like

wouldn’t it only work if the user types more than 1 charachter? I’m want it to switch immediately after the character is typed. For example whenever they write X i want LineEdit to be switched instantly.

well you can just pass the rejected substring to the new line edit and it will be the same as if they had typed the second character there

1 Like

You can also just hook into the text_changed and once the new_text reaches the desired length (1), get the next line edit in script and call grab_focus on it

1 Like

Thank you so much. it worked perfectly!

Thanks man!

1 Like

My pleasure!