@@ -3820,12 +3820,7 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
38203820 Input::get_singleton ()->set_mouse_mode (Input::MOUSE_MODE_VISIBLE);
38213821 warp_mouse (range_drag_capture_pos);
38223822 } else {
3823- Rect2 rect;
3824- if (select_mode == SELECT_ROW) {
3825- rect = get_selected ()->get_meta (" __focus_col_" + itos (selected_col));
3826- } else {
3827- rect = get_selected ()->get_meta (" __focus_rect" );
3828- }
3823+ Rect2 rect = _get_item_focus_rect (get_selected ());
38293824 Point2 mpos = mb->get_position ();
38303825 int icon_size_x = 0 ;
38313826 Ref<Texture2D> icon = get_selected ()->get_icon (selected_col);
@@ -4203,12 +4198,7 @@ bool Tree::edit_selected(bool p_force_edit) {
42034198 }
42044199
42054200 float popup_scale = popup_editor->is_embedded () ? 1.0 : popup_editor->get_parent_visible_window ()->get_content_scale_factor ();
4206- Rect2 rect;
4207- if (select_mode == SELECT_ROW) {
4208- rect = s->get_meta (" __focus_col_" + itos (selected_col));
4209- } else {
4210- rect = s->get_meta (" __focus_rect" );
4211- }
4201+ Rect2 rect = _get_item_focus_rect (s);
42124202 rect.position *= popup_scale;
42134203 popup_edited_item = s;
42144204 popup_edited_item_col = col;
@@ -4315,6 +4305,16 @@ bool Tree::edit_selected(bool p_force_edit) {
43154305 return false ;
43164306}
43174307
4308+ Rect2 Tree::_get_item_focus_rect (const TreeItem *p_item) const {
4309+ Rect2 rect;
4310+ if (select_mode == SELECT_ROW) {
4311+ rect = p_item->get_meta (" __focus_col_" + itos (selected_col));
4312+ } else {
4313+ rect = p_item->get_meta (" __focus_rect" );
4314+ }
4315+ return rect;
4316+ }
4317+
43184318bool Tree::is_editing () {
43194319 return popup_editor->is_visible ();
43204320}
@@ -4597,7 +4597,7 @@ void Tree::_notification(int p_what) {
45974597 case NOTIFICATION_RESIZED:
45984598 case NOTIFICATION_TRANSFORM_CHANGED: {
45994599 if (popup_edited_item != nullptr ) {
4600- Rect2 rect = popup_edited_item-> get_meta ( " __focus_rect " );
4600+ Rect2 rect = _get_item_focus_rect (popup_edited_item );
46014601
46024602 popup_editor->set_position (get_global_position () + rect.position );
46034603 popup_editor->set_size (rect.size );
0 commit comments