summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorGuilherme Felipe <guilhermefelipecgs@gmail.com>2018-05-16 11:43:00 -0300
committerGuilherme Felipe <guilhermefelipecgs@gmail.com>2018-05-16 12:11:20 -0300
commit22041264ed38b65379a46a54050448d3807b5936 (patch)
tree8157bffc7f4aaac4d9a8a8af1c8993bfd7126c60 /editor
parent93c4274941cf755c738a870eaeb71521da05cad3 (diff)
[Doc] Fixes in find bar
- Automatically select all text when find bar called. - Adjust the size height when first displayed.
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_help.cpp22
-rw-r--r--editor/editor_help.h2
2 files changed, 23 insertions, 1 deletions
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index f9b104cdae..b49c2d26d0 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -1978,8 +1978,27 @@ FindBar::FindBar() {
}
void FindBar::popup_search() {
+
show();
- search_text->grab_focus();
+ bool grabbed_focus = false;
+ if (!search_text->has_focus()) {
+ search_text->grab_focus();
+ grabbed_focus = true;
+ }
+
+ if (!search_text->get_text().empty()) {
+ search_text->select_all();
+ search_text->set_cursor_position(search_text->get_text().length());
+ if (grabbed_focus) {
+ _search();
+ }
+ }
+
+ call_deferred("_update_size");
+}
+
+void FindBar::_update_size() {
+
container->set_custom_minimum_size(Size2(0, hbc->get_size().height));
}
@@ -2016,6 +2035,7 @@ void FindBar::_bind_methods() {
ClassDB::bind_method("_search_next", &FindBar::search_next);
ClassDB::bind_method("_search_prev", &FindBar::search_prev);
ClassDB::bind_method("_hide_pressed", &FindBar::_hide_bar);
+ ClassDB::bind_method("_update_size", &FindBar::_update_size);
ADD_SIGNAL(MethodInfo("search"));
}
diff --git a/editor/editor_help.h b/editor/editor_help.h
index 35d98d274c..514169dc19 100644
--- a/editor/editor_help.h
+++ b/editor/editor_help.h
@@ -148,6 +148,8 @@ class FindBar : public HBoxContainer {
void _search_text_changed(const String &p_text);
void _search_text_entered(const String &p_text);
+ void _update_size();
+
protected:
void _notification(int p_what);
void _unhandled_input(const Ref<InputEvent> &p_event);