Skip to content

Add a property to LineEdit and TextEdit to make it not capture KEY_TAB (= ui_focus_next) #3050

Description

@goatchurchprime

Describe the project you are working on

VR cave survey with a keyboard driven UI interface

Describe the problem or limitation you are having in your project

If you set up a 2D Viewport with a user interface made from buttons and boxes, you can quickly TAB and SHIFT_TAB around it in the keyboard to reach the different options without touching the mouse.

This works until one of the nodes is a TextEdit or LineEdit, and then your TAB key will simply insert tab characters into the text and you can never escape from this part of the UI without resorting to clicking on something else with the mouse.

I note that parts of the Godot Editor do not suffer from this (I can tab across the different boxes on the left such as the "Filter nodes" or "Search files" TextLines or on the left hand pane of the editor), so this feature is used.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Given that it is present in the editor, a programmer expects the feature to be available, so if you're like me you waste quite a bit of time looking for it. If it's not supposed to be here, it should say so in the documentation so we can get straight to the ugly work-around (see below).

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

You could probably implement it as a FocusMode: FOCUS_DO_NOT_CAPTURE_TAB_KEYS option

If this enhancement will not be used often, can it be worked around with a few lines of script?

This has one work-around, where you have to attach a script to each text box that captures and implements the TAB key, but it's pretty ugly, especially if you have many editor boxes.
https://www.reddit.com/r/godot/comments/fvtwey/how_to_avoid_textedit_capturing_tab/

func _input(event):
	if event.is_action_pressed("ui_focus_prev") and has_focus():
		if focus_previous != "":
			get_node(focus_previous).grab_focus()
		get_tree().set_input_as_handled()
	elif event.is_action_pressed("ui_focus_next") and has_focus():
		if focus_next != "":
			get_node(focus_next).grab_focus()
		get_tree().set_input_as_handled()

Is there a reason why this should be core and not an add-on in the asset library?

This is a small feature on a core node.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions