mirror of
https://github.com/godotengine/godot.git
synced 2025-10-24 02:13:36 +00:00
fix(Tree): get_meta condition
If an item in a Tree has never been selected, its metadata "__focus_rect" is not set. If an unselected item is then edited (Tree::edit_selected()), an error is thrown in console.
This commit is contained in:
parent
3418f76a9e
commit
dcf65433f1
1 changed files with 9 additions and 10 deletions
|
|
@ -1181,23 +1181,22 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_item->cells[i].selected && select_mode != SELECT_ROW) {
|
if (select_mode != SELECT_ROW && (p_item->cells[i].selected || selected_item == p_item)) {
|
||||||
|
|
||||||
Rect2i r(cell_rect.position, cell_rect.size);
|
Rect2i r(cell_rect.position, cell_rect.size);
|
||||||
|
|
||||||
if (p_item->cells[i].text.size() > 0) {
|
if (p_item->cells[i].text.size() > 0) {
|
||||||
float icon_width = p_item->cells[i].get_icon_size().width;
|
float icon_width = p_item->cells[i].get_icon_size().width;
|
||||||
r.position.x += icon_width;
|
r.position.x += icon_width;
|
||||||
r.size.x -= icon_width;
|
r.size.x -= icon_width;
|
||||||
}
|
}
|
||||||
p_item->set_meta("__focus_rect", Rect2(r.position, r.size));
|
p_item->set_meta("__focus_rect", Rect2(r.position, r.size));
|
||||||
|
|
||||||
|
if (p_item->cells[i].selected) {
|
||||||
if (has_focus()) {
|
if (has_focus()) {
|
||||||
cache.selected_focus->draw(ci, r);
|
cache.selected_focus->draw(ci, r);
|
||||||
} else {
|
} else {
|
||||||
cache.selected->draw(ci, r);
|
cache.selected->draw(ci, r);
|
||||||
}
|
}
|
||||||
if (text_editor->is_visible_in_tree()) {
|
|
||||||
Vector2 ofs2(0, (text_editor->get_size().height - r.size.height) / 2);
|
|
||||||
text_editor->set_position(get_global_position() + r.position - ofs2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue