Trouble implementing $LineEdit.grab_focus()

Godot Version

4.4

Question

I am trying to use grab_focus() on my LineEdit node to prevent WASD keys from controlling movement elsewhere in my project when the player is typing in the LineEdit. I have looked it up in the Docs and found the following information under grab_focus():

“Has no effect for LineEdit and TextEdit when ProjectSettings.gui/common/show_focus_state_on_pointer_event is set to Text Input Controls, or for any control when it is set to Always.”

However, when I navigate to “Common” in my Project Settings, I do not see “show focus state on pointer controls.” This is what my settings look like:

I was hoping based on the information in the Docs that I could simply change a setting and use grab_focus() on a LineEdit node. Is this possible? How should I proceed? I don’t know if the issue is that I am using version 4.4 so the Doc is not always accurate/relevant to my version.

I appreciate any insights. Thank you!

func _unhandled_input shouldn’t recieve inputs if your line edit is currently consuming them. But I assume you are using Input.get_vector as part of your _physics_process. You may need to check if any gui has focus at that point in your code.

func _physics_process(delta: float) -> void:
    var input_dir := Input.get_vector(...)

    var focused_node: Control = get_viewport().gui_get_focus_owner()
    if focused_node != null and focused_node is LineEdit:
        input_dir = Vector2.ZERO

If this doesn’t help then make sure to paste your code too

I made a few tweeks, but this essentially worked perfectly, thanks!