summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2019-01-22 12:29:26 -0300
committerJuan Linietsky <reduzio@gmail.com>2019-01-22 12:29:26 -0300
commitc70c43c8885006d64224b08ea02e05af13827d73 (patch)
treeb7bc7355ef001b502b33458ccb0e1562664dd0c1
parent4333a68ca0d23eba398a1fc68674988d05ac11dc (diff)
Make inspector gain focus on refresh only if it has it, fixes #24979, closes #25053
-rw-r--r--editor/editor_inspector.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 0e5fd3a999..e660bb2daf 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -1366,7 +1366,28 @@ void EditorInspector::update_tree() {
//to update properly if all is refreshed
StringName current_selected = property_selected;
- int current_focusable = property_focusable;
+ int current_focusable = -1;
+
+ if (property_focusable != -1) {
+ //check focusable is really focusable
+ bool restore_focus = false;
+ Control *focused = get_focus_owner();
+ if (focused) {
+ Node *parent = focused->get_parent();
+ while (parent) {
+ EditorInspector *inspector = Object::cast_to<EditorInspector>(parent);
+ if (inspector) {
+ restore_focus = inspector == this; //may be owned by another inspector
+ break; //exit after the first inspector is found, since there may be nested ones
+ }
+ parent = parent->get_parent();
+ }
+ }
+
+ if (restore_focus) {
+ current_focusable = property_focusable;
+ }
+ }
_clear();