@@ -3285,9 +3285,6 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int
32853285		click_handled = true ;
32863286		popup_pressing_edited_item = p_item;
32873287		popup_pressing_edited_item_column = col;
3288- 
3289- 		pressing_item_rect = Rect2 (get_global_position () + Point2i (col_ofs, _get_title_button_height () + y_ofs) - theme_cache.offset , Size2 (col_width, item_h));
3290- 		pressing_for_editor_text = editor_text;
32913288		pressing_for_editor = true ;
32923289
32933290		return  -1 ; //  Select.
@@ -3361,14 +3358,15 @@ void Tree::_text_editor_gui_input(const Ref<InputEvent> &p_event) {
33613358	if  (p_event->is_action_pressed (" ui_text_newline_blank"  , true )) {
33623359		accept_event ();
33633360	} else  if  (p_event->is_action_pressed (" ui_text_newline"  )) {
3361+ 		bool  hide_focus = !text_editor->has_focus (true );
33643362		popup_edit_committed = true ; //  End edit popup processing.
33653363		popup_editor->hide ();
3366- 		_apply_multiline_edit ();
3364+ 		_apply_multiline_edit (hide_focus );
33673365		accept_event ();
33683366	}
33693367}
33703368
3371- void  Tree::_apply_multiline_edit () {
3369+ void  Tree::_apply_multiline_edit (bool  p_hide_focus ) {
33723370	if  (!popup_edited_item) {
33733371		return ;
33743372	}
@@ -3387,6 +3385,7 @@ void Tree::_apply_multiline_edit() {
33873385		}
33883386	}
33893387
3388+ 	grab_focus (p_hide_focus);
33903389	item_edited (popup_edited_item_col, popup_edited_item);
33913390	queue_redraw ();
33923391}
@@ -3400,6 +3399,8 @@ void Tree::_line_editor_submit(String p_text) {
34003399		return ; //  ESC pressed, app focus lost, or forced close from code.
34013400	}
34023401
3402+ 	bool  hide_focus = !line_editor->has_focus (true );
3403+ 
34033404	popup_edit_committed = true ; //  End edit popup processing.
34043405	popup_editor->hide ();
34053406
@@ -3432,6 +3433,7 @@ void Tree::_line_editor_submit(String p_text) {
34323433		}
34333434	}
34343435
3436+ 	grab_focus (hide_focus);
34353437	item_edited (popup_edited_item_col, popup_edited_item);
34363438	queue_redraw ();
34373439}
@@ -4404,6 +4406,8 @@ bool Tree::edit_selected(bool p_force_edit) {
44044406		}
44054407		popup_rect.position  += get_screen_position ();
44064408
4409+ 		bool  hide_focus = !has_focus (true );
4410+ 
44074411		line_editor->clear ();
44084412		line_editor->set_text (c.mode  == TreeItem::CELL_MODE_STRING ? c.text  : String::num (c.val , Math::range_step_decimals (c.step )));
44094413		line_editor->select_all ();
@@ -4420,10 +4424,12 @@ bool Tree::edit_selected(bool p_force_edit) {
44204424		popup_editor->popup ();
44214425		popup_editor->child_controls_changed ();
44224426
4423- 		line_editor->grab_focus ();
4427+ 		line_editor->grab_focus (hide_focus );
44244428
44254429		return  true ;
44264430	} else  if  (c.mode  == TreeItem::CELL_MODE_STRING && c.edit_multiline ) {
4431+ 		bool  hide_focus = !has_focus (true );
4432+ 
44274433		line_editor->hide ();
44284434
44294435		text_editor->clear ();
@@ -4440,7 +4446,7 @@ bool Tree::edit_selected(bool p_force_edit) {
44404446		popup_editor->popup ();
44414447		popup_editor->child_controls_changed ();
44424448
4443- 		text_editor->grab_focus ();
4449+ 		text_editor->grab_focus (hide_focus );
44444450
44454451		return  true ;
44464452	}
0 commit comments