diff options
Diffstat (limited to 'scene/gui/item_list.cpp')
-rw-r--r-- | scene/gui/item_list.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 02d44caa1c..e9d34fae3b 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -44,7 +44,7 @@ void ItemList::_shape_text(int p_idx) { } else { item.text_buf->set_direction((TextServer::Direction)item.text_direction); } - item.text_buf->add_string(item.text, theme_cache.font, theme_cache.font_size, item.language); + item.text_buf->add_string(item.xl_text, theme_cache.font, theme_cache.font_size, item.language); if (icon_mode == ICON_MODE_TOP && max_text_lines > 0) { item.text_buf->set_break_flags(TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::BREAK_GRAPHEME_BOUND | TextServer::BREAK_TRIM_EDGE_SPACES); } else { @@ -58,6 +58,7 @@ int ItemList::add_item(const String &p_item, const Ref<Texture2D> &p_texture, bo Item item; item.icon = p_texture; item.text = p_item; + item.xl_text = atr(p_item); item.selectable = p_selectable; items.push_back(item); int item_id = items.size() - 1; @@ -94,6 +95,7 @@ void ItemList::set_item_text(int p_idx, const String &p_text) { } items.write[p_idx].text = p_text; + items.write[p_idx].xl_text = atr(p_text); _shape_text(p_idx); queue_redraw(); shape_changed = true; @@ -1001,7 +1003,6 @@ void ItemList::_notification(int p_what) { } break; case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: - case NOTIFICATION_TRANSLATION_CHANGED: case NOTIFICATION_THEME_CHANGED: { for (int i = 0; i < items.size(); i++) { _shape_text(i); @@ -1009,6 +1010,14 @@ void ItemList::_notification(int p_what) { shape_changed = true; queue_redraw(); } break; + case NOTIFICATION_TRANSLATION_CHANGED: { + for (int i = 0; i < items.size(); i++) { + items.write[i].xl_text = atr(items[i].text); + _shape_text(i); + } + shape_changed = true; + queue_redraw(); + } break; case NOTIFICATION_DRAW: { force_update_list_size(); |