From 14c0630c1e110c5b507534e19e6c9607ba10df3e Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Thu, 25 Sep 2025 15:53:49 +0200 Subject: [PATCH] Added xml :loadLayoutFromString --- Basalt/plugins/reactive.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Basalt/plugins/reactive.lua b/Basalt/plugins/reactive.lua index 28274ee..4bf2ddf 100644 --- a/Basalt/plugins/reactive.lua +++ b/Basalt/plugins/reactive.lua @@ -207,6 +207,24 @@ return { self:addChild(object) end return self + end, + + loadLayoutFromString = function(self, xmlContent, props) + local wrappedProps = {} + if (props == nil) then + props = {} + end + for prop, value in pairs(props) do + wrappedProps[prop] = function() + return value + end + end + local layout = Layout.fromXML(xmlContent) + local objects = basalt.createObjectsFromLayout(layout, wrappedProps) + for _, object in ipairs(objects) do + self:addChild(object) + end + return self end } return object