diff --git a/Basalt/plugins/xml.lua b/Basalt/plugins/xml.lua index a214f33..3fcb1dc 100644 --- a/Basalt/plugins/xml.lua +++ b/Basalt/plugins/xml.lua @@ -187,6 +187,7 @@ return { if(xmlValue("width", data)~=nil)then w = xmlValue("width", data) end if(xmlValue("height", data)~=nil)then h = xmlValue("height", data) end if(xmlValue("background", data)~=nil)then self:setBackground(colors[xmlValue("background", data)]) end + if(xmlValue("foreground", data)~=nil)then self:setForeground(colors[xmlValue("foreground", data)]) end if(xmlValue("script", data)~=nil)then @@ -368,6 +369,19 @@ return { return object end, + Flexbox = function(base, basalt) + local object = { + setValuesByXMLData = function(self, data, scripts) + base.setValuesByXMLData(self, data, scripts) + if(xmlValue("flexDirection", data)~=nil)then self:setFlexDirection(xmlValue("flexDirection", data)) end + if(xmlValue("justifyContent", data)~=nil)then self:setJustifyContent(xmlValue("justifyContent", data)) end + if(xmlValue("spacing", data)~=nil)then self:setFlexDirection(xmlValue("spacing", data)) end + return self + end, + } + return object + end, + Button = function(base, basalt) local object = { setValuesByXMLData = function(self, data, scripts) @@ -762,4 +776,4 @@ return { return object end, -} \ No newline at end of file +} diff --git a/docs/objects/Basalt/schedule.md b/docs/objects/Basalt/schedule.md index 2ea0b7d..e946514 100644 --- a/docs/objects/Basalt/schedule.md +++ b/docs/objects/Basalt/schedule.md @@ -15,7 +15,7 @@ Schedules a function which gets called in a coroutine. After the coroutine is fi ### Usage -* Creates a schedule which switches the color between red and gray +Creates a schedule which switches the color between red and gray: ```lua local mainFrame = basalt.createFrame() @@ -34,3 +34,18 @@ aButton:onClick(basalt.schedule(function(self) self:setBackground(colors.gray) end)) ``` + +Usage in XML layout: + +```xml + +``` diff --git a/docs/objects/Object/onEvent.md b/docs/objects/Object/onEvent.md index fd825af..e4422be 100644 --- a/docs/objects/Object/onEvent.md +++ b/docs/objects/Object/onEvent.md @@ -14,7 +14,7 @@ You can find a full list here: [CC:Tweaked](https://tweaked.cc/) (on the left si ### Usage -* Add an onEvent event to your frame: +Add an onEvent event to your frame: ```lua local basalt = require("basalt") @@ -26,3 +26,22 @@ main:onEvent(function(event, side, channel, replyChannel, message, distance) end end) ``` + +The parameters passed to this function are the same as those returned by `os.pullEvent()`. See [here](https://tweaked.cc/module/os.html#v:pullEvent) for more info. + +Alternatively, you can add an onEvent event to an XML layout: + +```xml + + local eventType = event[2] + + if (eventType == "modem_message") then + local message = event[6] + basalt.debug("Message received: " .. message) + end + +``` + +In this case, the event table indices correspond to: +* 1: The Object where this event is being handled +* 2, 3,...: the `os.pullEvent()` parameters