Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unfocus LineEdit when pressing Escape #81128

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Aug 29, 2023

@KoBeWi KoBeWi added this to the 4.x milestone Aug 29, 2023
@KoBeWi KoBeWi requested a review from a team as a code owner August 29, 2023 12:55
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me.

More reviews from @godotengine/gui-nodes welcome.

@akien-mga akien-mga requested a review from a team August 29, 2023 13:10
@akien-mga akien-mga modified the milestones: 4.x, 4.2 Aug 29, 2023
@akien-mga akien-mga merged commit f7c48cf into godotengine:master Aug 30, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks!

@KoBeWi KoBeWi deleted the devourer_of_input_meets_destroyer_of_focus branch August 30, 2023 09:26
@Calinou
Copy link
Member

Calinou commented Aug 30, 2023

Would this make sense to do for TextEdit as well? It might be an issue for autocompletion users, so it'll surely have to be optional there. (I'd say it should be enabled by default still – we can disable it for specific things such as the script/shader editor.)

@KoBeWi
Copy link
Member Author

KoBeWi commented Aug 30, 2023

It could be used for multiline fields in the inspector, so IMO makes sense. (I also have a plugin that would benefit from this)

@nathanfranke
Copy link
Contributor

Probably should use accept_event(), this stops _unhandled_input from also being called for escape.

# gdscript not C++, but this works as expected on LineEdit
func _gui_input(event: InputEvent) -> void:
	if event.is_action(&"ui_cancel"):
		release_focus()
		accept_event()

Otherwise, if I have escape on unhandled input to reload current scene, I get this (separate bug?),

E 0:00:01:0304   release_focus: Condition "!is_inside_tree()" is true.
  <C++ Source>   scene/gui/control.cpp:2018 @ release_focus()

MRP:

func _unhandled_input(event: InputEvent) -> void:
	if event.is_action_pressed(&"ui_cancel"):
		get_tree().reload_current_scene()
# plus LineEdit somewhere

(Also, TextEdit makes sense yes)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allows SpinBox to drop focus when pressing Escape
5 participants