LineEdit remove arrow navigation

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Major_Sauce

Hello to all reading this post.

I´m currently fiddeling around with the LineEdit node.
Basically, I want to have custom functions for the KEY_UP and KEY_DOWN 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,

:bust_in_silhouette: Reply From: p7f


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():

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.

1 Like