Merge branch 'master' of https://github.com/Pyroxenium/Basalt
This commit is contained in:
@@ -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,
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
<button text="Click me">
|
||||
<onClick>
|
||||
basalt.schedule(function()
|
||||
local button = event[1]
|
||||
button:setBackground(colors.lime)
|
||||
os.sleep(1)
|
||||
button:setBackground(colors.black)
|
||||
end)()
|
||||
</onClick>
|
||||
</button>
|
||||
```
|
||||
|
||||
@@ -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
|
||||
<onEvent>
|
||||
local eventType = event[2]
|
||||
|
||||
if (eventType == "modem_message") then
|
||||
local message = event[6]
|
||||
basalt.debug("Message received: " .. message)
|
||||
end
|
||||
</onEvent>
|
||||
```
|
||||
|
||||
In this case, the event table indices correspond to:
|
||||
* 1: The Object where this event is being handled
|
||||
* 2, 3,...: the `os.pullEvent()` parameters
|
||||
|
||||
Reference in New Issue
Block a user