0 votes

i need to change focus to another lineedit, lineedit has property to set which is next lineedit to focus on, but as far as i know it is using tab key to trigger the next focus, how to change focus to the next lineedit, after user input 5 letter in previous lineedit,

Godot version 3.4
in Engine by (24 points)

i already using grab_focus() function, but i just want to know, is there another way using next focus property and trigger it using some condition from script,

1 Answer

0 votes

There should be something like a text_changed signal for LineEdit.


text_change_rejected ( String rejected_substring )

Emitted when appending text that overflows the maxlength. The
appended text is truncated to fit max
length, and the part that
couldn't fit is passed as the rejected_substring argument.

text_changed ( String new_text )

Emitted when the text changes.

text_entered ( String new_text )

Emitted when the user presses @GlobalScope.KEY_ENTER on the LineEdit.

LineEdit Godot

You should have that signal run anytime a key is pressed and when the length of the text has reach 5 use the grab_focus code to move to the next line edit.

func on_LineEdit(text_changed):
        if len(text) == 5: #Assumption: Code is in current LineEdit
               #Called grab_focus() code for LineEdit2.
by (98 points)

oo okay, thank you this gives me another way of thinking, using this way i need to define which lineedit i want to go next, like on every lineedit right?,

NodePath focusnext [default: NodePath("")]
focusnext(value) setter
focus_next() getter

Tells Godot which node it should give keyboard focus to if the user
presses Tab on a keyboard by default. You can change the key by
editing the uifocusnext input action.

If this property is not set, Godot will select a "best guess" based on
surrounding nodes in the scene tree.

this from focus_next doc

when i click tab key, godot "guessing" which is next lineedit, and i dont need to define that like $lineedit.grab_focus(), godot like "knows" which is the next lineedit

can i just go to "next" lineedit after certain condition is true, without defining it before because it is just next to it? is that possible?

is this understandable? im sorry my poor english, but thank you

This looks like what you are looking for but instead you want to emit uitab or uinext.

Godot InputEvents

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.