File tree Expand file tree Collapse file tree 3 files changed +14
-10
lines changed
Expand file tree Collapse file tree 3 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -4465,6 +4465,14 @@ void EditorInspector::_node_removed(Node *p_node) {
44654465 }
44664466}
44674467
4468+ void EditorInspector::_gui_focus_changed (Control *p_control) {
4469+ if (!is_visible_in_tree () && !is_following_focus ()) {
4470+ return ;
4471+ }
4472+ // Don't follow focus when the inspector nor any of its children is focused. Prevents potential jumping when gaining focus.
4473+ set_follow_focus (has_focus () || child_has_focus ());
4474+ }
4475+
44684476void EditorInspector::_update_current_favorites () {
44694477 current_favorites.clear ();
44704478 if (!can_favorite) {
@@ -4662,6 +4670,10 @@ void EditorInspector::_notification(int p_what) {
46624670 if (!is_sub_inspector ()) {
46634671 get_tree ()->connect (" node_removed" , callable_mp (this , &EditorInspector::_node_removed));
46644672 }
4673+
4674+ Viewport *viewport = get_viewport ();
4675+ ERR_FAIL_NULL (viewport);
4676+ viewport->connect (" gui_focus_changed" , callable_mp (this , &EditorInspector::_gui_focus_changed));
46654677 } break ;
46664678
46674679 case NOTIFICATION_PREDELETE: {
@@ -4744,15 +4756,6 @@ void EditorInspector::_notification(int p_what) {
47444756 update_tree ();
47454757 }
47464758 } break ;
4747-
4748- case NOTIFICATION_FOCUS_ENTER: {
4749- set_follow_focus (true );
4750- } break ;
4751-
4752- case NOTIFICATION_FOCUS_EXIT: {
4753- // Don't follow focus when the inspector is not focused. Prevents potential jumping when gaining focus.
4754- set_follow_focus (false );
4755- } break ;
47564759 }
47574760}
47584761
Original file line number Diff line number Diff line change @@ -606,6 +606,7 @@ class EditorInspector : public ScrollContainer {
606606 void _clear_current_favorites ();
607607
608608 void _node_removed (Node *p_node);
609+ void _gui_focus_changed (Control *p_control);
609610
610611 HashMap<StringName, int > per_array_page;
611612 void _page_change_request (int p_new_page, const StringName &p_array_prefix);
Original file line number Diff line number Diff line change @@ -82,7 +82,6 @@ class ScrollContainer : public Container {
8282
8383 bool draw_focus_border = false ;
8484 bool focus_border_is_drawn = false ;
85- bool child_has_focus ();
8685
8786protected:
8887 Size2 get_minimum_size () const override ;
@@ -99,6 +98,7 @@ class ScrollContainer : public Container {
9998
10099public:
101100 virtual void gui_input (const Ref<InputEvent> &p_gui_input) override ;
101+ bool child_has_focus ();
102102
103103 void set_h_scroll (int p_pos);
104104 int get_h_scroll () const ;
You canβt perform that action at this time.
0 commit comments