@@ -3822,12 +3822,7 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
38223822 Input::get_singleton ()->set_mouse_mode (Input::MOUSE_MODE_VISIBLE);
38233823 warp_mouse (range_drag_capture_pos);
38243824 } else {
3825- Rect2 rect;
3826- if (select_mode == SELECT_ROW) {
3827- rect = get_selected ()->get_meta (" __focus_col_" + itos (selected_col));
3828- } else {
3829- rect = get_selected ()->get_meta (" __focus_rect" );
3830- }
3825+ Rect2 rect = _get_item_focus_rect (get_selected ());
38313826 Point2 mpos = mb->get_position ();
38323827 int icon_size_x = 0 ;
38333828 Ref<Texture2D> icon = get_selected ()->get_icon (selected_col);
@@ -4205,12 +4200,7 @@ bool Tree::edit_selected(bool p_force_edit) {
42054200 }
42064201
42074202 float popup_scale = popup_editor->is_embedded () ? 1.0 : popup_editor->get_parent_visible_window ()->get_content_scale_factor ();
4208- Rect2 rect;
4209- if (select_mode == SELECT_ROW) {
4210- rect = s->get_meta (" __focus_col_" + itos (selected_col));
4211- } else {
4212- rect = s->get_meta (" __focus_rect" );
4213- }
4203+ Rect2 rect = _get_item_focus_rect (s);
42144204 rect.position *= popup_scale;
42154205 popup_edited_item = s;
42164206 popup_edited_item_col = col;
@@ -4317,6 +4307,16 @@ bool Tree::edit_selected(bool p_force_edit) {
43174307 return false ;
43184308}
43194309
4310+ Rect2 Tree::_get_item_focus_rect (const TreeItem *p_item) const {
4311+ Rect2 rect;
4312+ if (select_mode == SELECT_ROW) {
4313+ rect = p_item->get_meta (" __focus_col_" + itos (selected_col));
4314+ } else {
4315+ rect = p_item->get_meta (" __focus_rect" );
4316+ }
4317+ return rect;
4318+ }
4319+
43204320bool Tree::is_editing () {
43214321 return popup_editor->is_visible ();
43224322}
@@ -4599,7 +4599,7 @@ void Tree::_notification(int p_what) {
45994599 case NOTIFICATION_RESIZED:
46004600 case NOTIFICATION_TRANSFORM_CHANGED: {
46014601 if (popup_edited_item != nullptr ) {
4602- Rect2 rect = popup_edited_item-> get_meta ( " __focus_rect " );
4602+ Rect2 rect = _get_item_focus_rect (popup_edited_item );
46034603
46044604 popup_editor->set_position (get_global_position () + rect.position );
46054605 popup_editor->set_size (rect.size );
0 commit comments