0 votes

Hello to all reading this post.

I´m currently fiddeling around with the LineEdit node.
Basically, I want to have custom functions for the KEYUP and KEYDOWN event on the line edit, unfortunatly, it uses those keys internally to navigate in the line (Up moves the cursor to the beginning of the line, down moves it to the end).
Is there any way to disable this behaviour ? I guess I´m just too blind or to dumb to find it...

Best regards,
Major

asked Jan 7, 2019 in Engine by Major_Sauce (18 points)

1 Answer

0 votes
Best answer

Hi,

You can use set_input_as_handled inside _input() so it does not propagate and does not the funciton intended on the line edit.. for example:

func _input(event):
    if event.is_action_pressed("ui_up") and $LineEdit.has_focus():
        print("up")
        get_tree().set_input_as_handled()

That script is set on a main scene that hase LineEdit as child. If you press up arrow when focusing the LineEdit, it will print "up" and exit, and wont do the effect expected on the LineEdit.

answered Jan 7, 2019 by p7f (2,654 points)
selected Mar 16, 2019 by Major_Sauce
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 How to use this Q&A? before posting your first questions.