Rich Text add on layout change

This commit is contained in:
Insality 2023-08-27 13:40:49 +03:00
parent 73ed0c8cd0
commit ca8c4e2425

View File

@ -124,6 +124,15 @@ function RichText.init(self, template, nodes)
end end
function RichText.on_layout_change(self)
gui.set_enabled(self.text_prefab, false)
gui.set_enabled(self.icon_prefab, false)
if self._last_value then
self:set_text(self._last_value)
end
end
--- Component style params. --- Component style params.
-- You can override this component styles params in Druid styles table -- You can override this component styles params in Druid styles table
-- or create your own style -- or create your own style
@ -189,6 +198,7 @@ end
-- <img=texture:image,width,height/> -- <img=texture:image,width,height/>
function RichText.set_text(self, text) function RichText.set_text(self, text)
self:clear() self:clear()
self._last_value = text
local words, settings, line_metrics = rich_text.create(text, self._settings, self.style) local words, settings, line_metrics = rich_text.create(text, self._settings, self.style)
line_metrics = rich_text.adjust_to_area(words, settings, line_metrics, self.style) line_metrics = rich_text.adjust_to_area(words, settings, line_metrics, self.style)
@ -211,6 +221,7 @@ function RichText:clear()
rich_text.remove(self._words) rich_text.remove(self._words)
self._words = nil self._words = nil
end end
self._last_value = nil
end end