mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Fix Escape does not work the first time when pressed at the Find(Replace)Bar
This commit is contained in:
parent
1586c5674b
commit
4d488e8cc9
4 changed files with 18 additions and 22 deletions
|
@ -4581,6 +4581,7 @@ EditorHelpHighlighter::~EditorHelpHighlighter() {
|
|||
FindBar::FindBar() {
|
||||
search_text = memnew(LineEdit);
|
||||
add_child(search_text);
|
||||
search_text->set_keep_editing_on_text_submit(true);
|
||||
search_text->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
|
||||
search_text->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
search_text->connect(SceneStringName(text_changed), callable_mp(this, &FindBar::_search_text_changed));
|
||||
|
@ -4644,7 +4645,7 @@ void FindBar::_notification(int p_what) {
|
|||
} break;
|
||||
|
||||
case NOTIFICATION_VISIBILITY_CHANGED: {
|
||||
set_process_unhandled_input(is_visible_in_tree());
|
||||
set_process_input(is_visible_in_tree());
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
@ -4721,12 +4722,15 @@ void FindBar::_hide_bar() {
|
|||
hide();
|
||||
}
|
||||
|
||||
void FindBar::unhandled_input(const Ref<InputEvent> &p_event) {
|
||||
// Implemented in input(..) as the LineEdit consumes the Escape pressed key.
|
||||
void FindBar::input(const Ref<InputEvent> &p_event) {
|
||||
ERR_FAIL_COND(p_event.is_null());
|
||||
|
||||
Ref<InputEventKey> k = p_event;
|
||||
if (k.is_valid() && k->is_action_pressed(SNAME("ui_cancel"), false, true)) {
|
||||
if (rich_text_label->has_focus() || is_ancestor_of(get_viewport()->gui_get_focus_owner())) {
|
||||
Control *focus_owner = get_viewport()->gui_get_focus_owner();
|
||||
|
||||
if (rich_text_label->has_focus() || (focus_owner && is_ancestor_of(focus_owner))) {
|
||||
_hide_bar();
|
||||
accept_event();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue