docs
This commit is contained in:
@@ -34,9 +34,9 @@ return function(name)
|
|||||||
return pos
|
return pos
|
||||||
end
|
end
|
||||||
|
|
||||||
local function updateColors()
|
local function updateColors(self)
|
||||||
local fgLine = tHex[base.fgColor]:rep(fgLines[textY]:len())
|
local fgLine = tHex[self.fgColor]:rep(fgLines[textY]:len())
|
||||||
local bgLine = tHex[base.bgColor]:rep(bgLines[textY]:len())
|
local bgLine = tHex[self.bgColor]:rep(bgLines[textY]:len())
|
||||||
for k,v in pairs(rules)do
|
for k,v in pairs(rules)do
|
||||||
local pos = stringGetPositions(lines[textY], v[1])
|
local pos = stringGetPositions(lines[textY], v[1])
|
||||||
if(#pos>0)then
|
if(#pos>0)then
|
||||||
@@ -68,8 +68,8 @@ return function(name)
|
|||||||
|
|
||||||
local object = {
|
local object = {
|
||||||
init = function(self)
|
init = function(self)
|
||||||
base.bgColor = self.parent:getTheme("TextfieldBG")
|
self.bgColor = self.parent:getTheme("TextfieldBG")
|
||||||
base.fgColor = self.parent:getTheme("TextfieldText")
|
self.fgColor = self.parent:getTheme("TextfieldText")
|
||||||
end,
|
end,
|
||||||
getType = function(self)
|
getType = function(self)
|
||||||
return objectType
|
return objectType
|
||||||
@@ -78,8 +78,8 @@ return function(name)
|
|||||||
setValuesByXMLData = function(self, data)
|
setValuesByXMLData = function(self, data)
|
||||||
base.setValuesByXMLData(self, data)
|
base.setValuesByXMLData(self, data)
|
||||||
if(data["lines"]~=nil)then
|
if(data["lines"]~=nil)then
|
||||||
for k,v in pairs(data["lines"])do
|
for k,v in pairs(data["lines"]["line"])do
|
||||||
self:addLine(xmlValue("line", v))
|
self:addLine(v:value())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if(data["keywords"]~=nil)then
|
if(data["keywords"]~=nil)then
|
||||||
@@ -100,13 +100,13 @@ return function(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if(data["rules"]~=nil)then
|
if(data["rules"]~=nil)then
|
||||||
if(data["rules"]["item"]~=nil)then
|
if(data["rules"]["rule"]~=nil)then
|
||||||
local tab = data["rules"]["item"]
|
local tab = data["rules"]["rule"]
|
||||||
if(data["rules"]["item"].properties~=nil)then tab = {data["rules"]["item"]} end
|
if(data["rules"]["rule"].properties~=nil)then tab = {data["rules"]["rule"]} end
|
||||||
for k,v in pairs(tab)do
|
for k,v in pairs(tab)do
|
||||||
|
|
||||||
if(xmlValue("rule", v)~=nil)then
|
if(xmlValue("pattern", v)~=nil)then
|
||||||
self:addRule(xmlValue("rule", v), colors[xmlValue("fg", v)], colors[xmlValue("bg", v)])
|
self:addRule(xmlValue("pattern", v), colors[xmlValue("fg", v)], colors[xmlValue("bg", v)])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -118,7 +118,7 @@ return function(name)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
getLine = function(self, index)
|
getLine = function(self, index)
|
||||||
return lines[index] or ""
|
return lines[index]
|
||||||
end;
|
end;
|
||||||
|
|
||||||
editLine = function(self, index, text)
|
editLine = function(self, index, text)
|
||||||
@@ -127,10 +127,22 @@ return function(name)
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
addLine = function(self, text, index)
|
addLine = function(self, text, index)
|
||||||
|
if(text~=nil)then
|
||||||
|
if(#lines==1)and(lines[1]=="")then
|
||||||
|
lines[1] = text
|
||||||
|
bgLines[1] = tHex[self.bgColor]:rep(text:len())
|
||||||
|
fgLines[1] = tHex[self.fgColor]:rep(text:len())
|
||||||
|
return self
|
||||||
|
end
|
||||||
if (index ~= nil) then
|
if (index ~= nil) then
|
||||||
table.insert(lines, index, text)
|
table.insert(lines, index, text)
|
||||||
|
table.insert(bgLines, index, tHex[self.bgColor]:rep(text:len()))
|
||||||
|
table.insert(fgLines, tHex[self.fgColor]:rep(text:len()))
|
||||||
else
|
else
|
||||||
table.insert(lines, text)
|
table.insert(lines, text)
|
||||||
|
table.insert(bgLines, tHex[self.bgColor]:rep(text:len()))
|
||||||
|
table.insert(fgLines, tHex[self.fgColor]:rep(text:len()))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end;
|
end;
|
||||||
@@ -253,7 +265,7 @@ return function(name)
|
|||||||
if (textY < hIndex) then
|
if (textY < hIndex) then
|
||||||
hIndex = hIndex - 1
|
hIndex = hIndex - 1
|
||||||
end
|
end
|
||||||
updateColors()
|
updateColors(self)
|
||||||
self:setValue("")
|
self:setValue("")
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -271,7 +283,7 @@ return function(name)
|
|||||||
fgLines[textY] = fgLines[textY]:sub(1, textX - 1) .. fgLines[textY]:sub(textX + 1, fgLines[textY]:len())
|
fgLines[textY] = fgLines[textY]:sub(1, textX - 1) .. fgLines[textY]:sub(textX + 1, fgLines[textY]:len())
|
||||||
bgLines[textY] = bgLines[textY]:sub(1, textX - 1) .. bgLines[textY]:sub(textX + 1, bgLines[textY]:len())
|
bgLines[textY] = bgLines[textY]:sub(1, textX - 1) .. bgLines[textY]:sub(textX + 1, bgLines[textY]:len())
|
||||||
end
|
end
|
||||||
updateColors()
|
updateColors(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (key == keys.enter) then
|
if (key == keys.enter) then
|
||||||
@@ -380,7 +392,7 @@ return function(name)
|
|||||||
if (textX >= w + wIndex) then
|
if (textX >= w + wIndex) then
|
||||||
wIndex = wIndex + 1
|
wIndex = wIndex + 1
|
||||||
end
|
end
|
||||||
updateColors()
|
updateColors(self)
|
||||||
self:setValue("")
|
self:setValue("")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,12 @@ Sets the displayed button text
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a button with "Click me!" as text.
|
* Creates a button with "Click me!" as text.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local button = mainFrame:addButton("myFirstButton"):setText("Click me!"):show()
|
local button = mainFrame:addButton():setText("Click me!")
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<button text="Click me!" />
|
||||||
```
|
```
|
||||||
|
|
||||||
## setHorizontalAlign
|
## setHorizontalAlign
|
||||||
@@ -29,11 +33,14 @@ Sets the horizontal align of the button text
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Sets the button's horizontal text align to right.
|
* Sets the button's horizontal text align to right.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame():show()
|
||||||
local button = mainFrame:addButton("myFirstButton")
|
local button = mainFrame:addButton()
|
||||||
:setText("Click me!")
|
:setText("Click me!")
|
||||||
:setHorizontalAlign("right")
|
:setHorizontalAlign("right")
|
||||||
:show()
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<button text="Click me!" horizontalAlign="right" />
|
||||||
```
|
```
|
||||||
|
|
||||||
## setVerticalAlign
|
## setVerticalAlign
|
||||||
@@ -48,19 +55,22 @@ Sets the vertical align of the button text
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Sets the button's horizontal text align to right and the vertical text align to bottom.
|
* Sets the button's horizontal text align to right and the vertical text align to bottom.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame():show()
|
||||||
local button = mainFrame:addButton("myFirstButton")
|
local button = mainFrame:addButton()
|
||||||
:setText("Click me!")
|
:setText("Click me!")
|
||||||
:setHorizontalAlign("right")
|
:setHorizontalAlign("right")
|
||||||
:setVerticalAlign("bottom")
|
:setVerticalAlign("bottom")
|
||||||
:show()
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<button text="Click me!" horizontalAlign="right" verticalAlign="bottom" />
|
||||||
```
|
```
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
This is a example on how you would create a fully working button:
|
This is a example on how you would create a fully working button:
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame():show()
|
||||||
local aButton = mainFrame:addButton("myFirstButton"):setText("Click"):show()
|
local aButton = mainFrame:addButton():setText("Click"):show()
|
||||||
|
|
||||||
aButton:onClick(function(self,event,button,x,y)
|
aButton:onClick(function(self,event,button,x,y)
|
||||||
if(event=="mouse_click")and(button==1)then
|
if(event=="mouse_click")and(button==1)then
|
||||||
@@ -68,3 +78,18 @@ aButton:onClick(function(self,event,button,x,y)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Lua and XML:
|
||||||
|
```lua
|
||||||
|
local mainFrame = basalt.createFrame():addLayout("example.xml")
|
||||||
|
|
||||||
|
basalt.setVariable("buttonClick", function(self,event,button,x,y)
|
||||||
|
if(event=="mouse_click")and(button==1)then
|
||||||
|
basalt.debug("Left mousebutton got clicked!")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<button onClick="buttonClick" text="Click me!" horizontalAlign="right" verticalAlign="bottom" />
|
||||||
|
```
|
||||||
@@ -7,14 +7,27 @@ A checkbox does not have any custom methods. All required methods are provided b
|
|||||||
# Example
|
# Example
|
||||||
This is how you would create a event which gets fired as soon as the value gets changed.
|
This is how you would create a event which gets fired as soon as the value gets changed.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):show()
|
local aCheckbox = mainFrame:addCheckbox()
|
||||||
|
|
||||||
local function checkboxChange(self)
|
local function checkboxChange(self)
|
||||||
local checked = self:getValue()
|
local checked = self:getValue()
|
||||||
basalt.debug("The value got changed into ", checked) end)
|
basalt.debug("The value got changed into ", checked)
|
||||||
end
|
end
|
||||||
aCheckbox:onChange(checkboxChange)
|
aCheckbox:onChange(checkboxChange)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Lua and XML:
|
||||||
|
```lua
|
||||||
|
local mainFrame = basalt.createFrame():addLayout("example.xml")
|
||||||
|
|
||||||
|
basalt.setVariable("checkboxChange", function(self)
|
||||||
|
local checked = self:getValue()
|
||||||
|
basalt.debug("The value got changed into ", checked)
|
||||||
|
end)
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<button onChange="checkboxChange" />
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -28,12 +28,17 @@ Adds a item into the dropdown
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default dropdown with 3 entries
|
* Creates a default dropdown with 3 entries
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
|
local aDropdown = mainFrame:addDropdown()
|
||||||
aDropdown:addItem("1. Entry")
|
aDropdown:addItem("1. Entry")
|
||||||
aDropdown:addItem("2. Entry",colors.yellow)
|
aDropdown:addItem("2. Entry",colors.yellow)
|
||||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||||
```
|
```
|
||||||
|
<dropdown>
|
||||||
|
<item><text>1. Entry</text></item>
|
||||||
|
<item><text>2. Entry</text><bg>yellow</bg></item>
|
||||||
|
<item><text>3. Entry</text><bg>yellow</bg><fg>green</fg></item>
|
||||||
|
</dropdown>
|
||||||
|
|
||||||
## removeItem
|
## removeItem
|
||||||
Removes a item from the dropdown
|
Removes a item from the dropdown
|
||||||
@@ -47,8 +52,8 @@ Removes a item from the dropdown
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default dropdown with 3 entries and removes the second one.
|
* Creates a default dropdown with 3 entries and removes the second one.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
|
local aDropdown = mainFrame:addDropdown()
|
||||||
aDropdown:addItem("1. Entry")
|
aDropdown:addItem("1. Entry")
|
||||||
aDropdown:addItem("2. Entry",colors.yellow)
|
aDropdown:addItem("2. Entry",colors.yellow)
|
||||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||||
@@ -71,8 +76,8 @@ Edits a item from the dropdown
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default dropdown with 3 entries and edits the second one.
|
* Creates a default dropdown with 3 entries and edits the second one.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
|
local aDropdown = mainFrame:addDropdown()
|
||||||
aDropdown:addItem("1. Entry")
|
aDropdown:addItem("1. Entry")
|
||||||
aDropdown:addItem("2. Entry",colors.yellow)
|
aDropdown:addItem("2. Entry",colors.yellow)
|
||||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||||
@@ -91,8 +96,8 @@ Returns a item by index
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default dropdown with 3 entries and edits the second one.
|
* Creates a default dropdown with 3 entries and edits the second one.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
|
local aDropdown = mainFrame:addDropdown()
|
||||||
aDropdown:addItem("1. Entry")
|
aDropdown:addItem("1. Entry")
|
||||||
aDropdown:addItem("2. Entry",colors.yellow)
|
aDropdown:addItem("2. Entry",colors.yellow)
|
||||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||||
@@ -108,8 +113,8 @@ Returns the current item count
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default dropdown with 3 entries and prints the current item count.
|
* Creates a default dropdown with 3 entries and prints the current item count.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
|
local aDropdown = mainFrame:addDropdown()
|
||||||
aDropdown:addItem("1. Entry")
|
aDropdown:addItem("1. Entry")
|
||||||
aDropdown:addItem("2. Entry",colors.yellow)
|
aDropdown:addItem("2. Entry",colors.yellow)
|
||||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||||
@@ -125,34 +130,14 @@ Returns all items as table
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default menubar with 3 entries and prints a table.
|
* Creates a default menubar with 3 entries and prints a table.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
|
local aDropdown = mainFrame:addDropdown()
|
||||||
aDropdown:addItem("1. Entry")
|
aDropdown:addItem("1. Entry")
|
||||||
aDropdown:addItem("2. Entry",colors.yellow)
|
aDropdown:addItem("2. Entry",colors.yellow)
|
||||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||||
basalt.debug(aDropdown:getAll())
|
basalt.debug(aDropdown:getAll())
|
||||||
```
|
```
|
||||||
|
|
||||||
## setScrollable
|
|
||||||
Makes the dropdown scrollable.
|
|
||||||
|
|
||||||
#### Parameters:
|
|
||||||
1. `boolean` if the dropdown should be scrollable or not
|
|
||||||
|
|
||||||
#### Returns:
|
|
||||||
1. `object` The object in use
|
|
||||||
|
|
||||||
#### Usage:
|
|
||||||
* Creates a default dropdown with 3 entries and makes it scrollable.
|
|
||||||
```lua
|
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
|
||||||
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
|
|
||||||
aDropdown:addItem("1. Entry")
|
|
||||||
aDropdown:addItem("2. Entry",colors.yellow)
|
|
||||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
|
||||||
aDropdown:setScrollable(true)
|
|
||||||
```
|
|
||||||
|
|
||||||
## selectItem
|
## selectItem
|
||||||
selects a item in the dropdown (same as a player would click on a item)
|
selects a item in the dropdown (same as a player would click on a item)
|
||||||
|
|
||||||
@@ -165,8 +150,8 @@ selects a item in the dropdown (same as a player would click on a item)
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default dropdown with 3 entries and selects the second entry.
|
* Creates a default dropdown with 3 entries and selects the second entry.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
|
local aDropdown = mainFrame:addDropdown()
|
||||||
aDropdown:addItem("1. Entry")
|
aDropdown:addItem("1. Entry")
|
||||||
aDropdown:addItem("2. Entry",colors.yellow)
|
aDropdown:addItem("2. Entry",colors.yellow)
|
||||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||||
@@ -182,8 +167,8 @@ Removes all items.
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default dropdown with 3 entries and removes them immediatley. Which makes no sense.
|
* Creates a default dropdown with 3 entries and removes them immediatley. Which makes no sense.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
|
local aDropdown = mainFrame:addDropdown()
|
||||||
aDropdown:addItem("1. Entry")
|
aDropdown:addItem("1. Entry")
|
||||||
aDropdown:addItem("2. Entry",colors.yellow)
|
aDropdown:addItem("2. Entry",colors.yellow)
|
||||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||||
@@ -199,8 +184,8 @@ returns the item index of the currently selected item
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default dropdown with 3 entries selects the second entry and prints the currently selected index.
|
* Creates a default dropdown with 3 entries selects the second entry and prints the currently selected index.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
|
local aDropdown = mainFrame:addDropdown()
|
||||||
aDropdown:addItem("1. Entry")
|
aDropdown:addItem("1. Entry")
|
||||||
aDropdown:addItem("2. Entry",colors.yellow)
|
aDropdown:addItem("2. Entry",colors.yellow)
|
||||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||||
@@ -221,16 +206,24 @@ Sets the background and the foreground of the item which is currently selected
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default dropdown with 4 entries and sets the selection background color to green.
|
* Creates a default dropdown with 4 entries and sets the selection background color to green.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
|
local aDropdown = mainFrame:addDropdown()
|
||||||
aDropdown:addItem("1. Entry")
|
aDropdown:addItem("1. Entry")
|
||||||
aDropdown:addItem("2. Entry",colors.yellow)
|
aDropdown:addItem("2. Entry",colors.yellow)
|
||||||
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
aDropdown:addItem("3. Entry",colors.yellow,colors.green)
|
||||||
aDropdown:addItem("4. Entry")
|
aDropdown:addItem("4. Entry")
|
||||||
aDropdown:setSelectedItem(colors.green)
|
aDropdown:setSelectedItem(colors.green, colors.red)
|
||||||
```
|
```
|
||||||
|
|
||||||
## setIndexOffset
|
```xml
|
||||||
|
<dropdown selectionBG="green" selectionFG="red">
|
||||||
|
<item><text>1. Entry</text></item>
|
||||||
|
<item><text>2. Entry</text><bg>yellow</bg></item>
|
||||||
|
<item><text>2. Entry</text><bg>yellow</bg><fg>green</fg></item>
|
||||||
|
</dropdown>
|
||||||
|
```
|
||||||
|
|
||||||
|
## setOffset
|
||||||
Sets the offset of the dropdown (the same as you would scroll) - default is 0
|
Sets the offset of the dropdown (the same as you would scroll) - default is 0
|
||||||
|
|
||||||
#### Parameters:
|
#### Parameters:
|
||||||
@@ -242,19 +235,29 @@ Sets the offset of the dropdown (the same as you would scroll) - default is 0
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default dropdown with 6 entries and sets the offset to 3.
|
* Creates a default dropdown with 6 entries and sets the offset to 3.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
|
local aDropdown = mainFrame:addDropdown()
|
||||||
aDropdown:addItem("1. Entry")
|
:addItem("1. Entry")
|
||||||
aDropdown:addItem("2. Entry")
|
:addItem("2. Entry")
|
||||||
aDropdown:addItem("3. Entry")
|
:addItem("3. Entry")
|
||||||
aDropdown:addItem("4. Entry")
|
:addItem("4. Entry")
|
||||||
aDropdown:addItem("5. Entry")
|
:addItem("5. Entry")
|
||||||
aDropdown:addItem("6. Entry")
|
:addItem("6. Entry")
|
||||||
aDropdown:setIndexOffset(3)
|
:setOffset(3)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<dropdown offset="3">
|
||||||
|
<item><text>1. Entry</text></item>
|
||||||
|
<item><text>2. Entry</text></item>
|
||||||
|
<item><text>3. Entry</text></item>
|
||||||
|
<item><text>4. Entry</text></item>
|
||||||
|
<item><text>5. Entry</text></item>
|
||||||
|
<item><text>6. Entry</text></item>
|
||||||
|
</dropdown>
|
||||||
|
```
|
||||||
|
|
||||||
## getIndexOffset
|
## getOffset
|
||||||
Returns the current index offset
|
Returns the current index offset
|
||||||
|
|
||||||
#### Returns:
|
#### Returns:
|
||||||
@@ -263,16 +266,16 @@ Returns the current index offset
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default dropdown with 6 entries and sets the offset to 3, also prints the current offset.
|
* Creates a default dropdown with 6 entries and sets the offset to 3, also prints the current offset.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):show()
|
local aDropdown = mainFrame:addDropdown()
|
||||||
aDropdown:addItem("1. Entry")
|
:addItem("1. Entry")
|
||||||
aDropdown:addItem("2. Entry")
|
:addItem("2. Entry")
|
||||||
aDropdown:addItem("3. Entry")
|
:addItem("3. Entry")
|
||||||
aDropdown:addItem("4. Entry")
|
:addItem("4. Entry")
|
||||||
aDropdown:addItem("5. Entry")
|
:addItem("5. Entry")
|
||||||
aDropdown:addItem("6. Entry")
|
:addItem("6. Entry")
|
||||||
aDropdown:setIndexOffset(3)
|
:setOffset(3)
|
||||||
basalt.debug(aDropdown:getIndexOffset())
|
basalt.debug(aDropdown:getOffset())
|
||||||
```
|
```
|
||||||
|
|
||||||
## setDropdownSize
|
## setDropdownSize
|
||||||
@@ -288,10 +291,18 @@ Sets the size of the opened dropdown
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default dropdown, adds 3 entries and sets the dropdown size to 15w, 8h
|
* Creates a default dropdown, adds 3 entries and sets the dropdown size to 15w, 8h
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aDropdown = mainFrame:addDropdown("myFirstDropdown"):setDropdownSize(15,8):show()
|
local aDropdown = mainFrame:addDropdown():setDropdownSize(15,8)
|
||||||
aDropdown:addItem("1. Entry")
|
aDropdown:addItem("1. Entry")
|
||||||
aDropdown:addItem("2. Entry")
|
aDropdown:addItem("2. Entry")
|
||||||
aDropdown:addItem("3. Entry")
|
aDropdown:addItem("3. Entry")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<dropdown dropdownWidth="15" dropdownHeight="8">
|
||||||
|
<item><text>1. Entry</text></item>
|
||||||
|
<item><text>2. Entry</text></item>
|
||||||
|
<item><text>3. Entry</text></item>
|
||||||
|
</dropdown>
|
||||||
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -29,10 +29,14 @@ Creates a child frame on the frame, the same as [basalt.createFrame](https://git
|
|||||||
1. `frame | nil` The frame created by addFrame, or `nil` if there is already a child frame with the given name.<br>
|
1. `frame | nil` The frame created by addFrame, or `nil` if there is already a child frame with the given name.<br>
|
||||||
|
|
||||||
#### Usage:
|
#### Usage:
|
||||||
* Create a frame with id "myFirstFrame" then create a child of that frame, named "myFirstSubFrame"
|
* Create a new main frame and adds a child frame to it
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame")
|
local mainFrame = basalt.createFrame()
|
||||||
local myFrame = mainFrame:addFrame("myFirstSubFrame")
|
local myFrame = mainFrame:addFrame()
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<frame></frame>
|
||||||
```
|
```
|
||||||
|
|
||||||
## setBar
|
## setBar
|
||||||
@@ -53,15 +57,18 @@ frame:setBar("My first Frame!", colors.black, colors.lightGray)
|
|||||||
```
|
```
|
||||||
* Store the frame, use the named frame variable after assigning.
|
* Store the frame, use the named frame variable after assigning.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local myFrame = MainFrame:addFrame("myFirstSubFrame")
|
local myFrame = MainFrame:addFrame()
|
||||||
myFrame:setBar("My first Frame!")
|
myFrame:setBar("My first Frame!")
|
||||||
myFrame:show()
|
|
||||||
```
|
```
|
||||||
* This abuses the call-chaining that Basalt uses.
|
* This abuses the call-chaining that Basalt uses.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local myFrame = mainFrame:addFrame("myFirstSubFrame"):setBar("My first Frame!"):show()
|
local myFrame = mainFrame:addFrame():setBar("My first Frame!")
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<frame barText="My first Frame!" barBG="black" barFG="lightGray"></frame>
|
||||||
```
|
```
|
||||||
|
|
||||||
## setBarTextAlign
|
## setBarTextAlign
|
||||||
@@ -76,7 +83,11 @@ Sets the frame's bar-text alignment
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Set the title of myFrame to "My first frame!", and align it to the right.
|
* Set the title of myFrame to "My first frame!", and align it to the right.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = myFrame:setBar("My first Frame!"):setBarTextAlign("right")
|
myFrame:setBar("My first Frame!"):setBarTextAlign("right")
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<frame barAlign="right"></frame>
|
||||||
```
|
```
|
||||||
|
|
||||||
## showBar
|
## showBar
|
||||||
@@ -91,9 +102,14 @@ Toggles the frame's upper bar
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Sets myFrame to have a bar titled "Hello World!" and subsequently displays it.
|
* Sets myFrame to have a bar titled "Hello World!" and subsequently displays it.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = myFrame:setBar("Hello World!"):showBar()
|
myFrame:setBar("Hello World!"):showBar()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<frame bar="true"></frame>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## setMonitor
|
## setMonitor
|
||||||
Sets this frame as a monitor frame
|
Sets this frame as a monitor frame
|
||||||
|
|
||||||
@@ -106,10 +122,34 @@ Sets this frame as a monitor frame
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a new monitor frame, you can use to show objects on a monitor.
|
* Creates a new monitor frame, you can use to show objects on a monitor.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("mainFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local monitorFrame = basalt.createFrame("mainFrame"):setMonitor("right"):show()
|
local monitorFrame = basalt.createFrame():setMonitor("right")
|
||||||
monitorFrame:setBar("Monitor 1"):showBar()
|
monitorFrame:setBar("Monitor 1"):showBar()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<frame monitor="right"></frame>
|
||||||
|
```
|
||||||
|
|
||||||
|
## setMirror
|
||||||
|
mirrors this frame to another peripheral monitor object.
|
||||||
|
|
||||||
|
#### Parameters:
|
||||||
|
1. `string` The monitor name ("right", "left",... "monitor_1", "monitor_2",...)
|
||||||
|
|
||||||
|
#### Returns:
|
||||||
|
1. `frame` The frame being used
|
||||||
|
|
||||||
|
#### Usage:
|
||||||
|
* Creates mirror of your main frame to a monitor on the left side.
|
||||||
|
```lua
|
||||||
|
local mainFrame = basalt.createFrame():setMirror("left")
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<frame mirror="left"></frame>
|
||||||
|
```
|
||||||
|
|
||||||
## getObject
|
## getObject
|
||||||
Returns a child object of the frame
|
Returns a child object of the frame
|
||||||
|
|
||||||
@@ -152,11 +192,12 @@ Sets the currently focused object
|
|||||||
1. `frame` The frame being used
|
1. `frame` The frame being used
|
||||||
|
|
||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates button with id "myFirstButton", sets the focused object to the previously mentioned button
|
* Creates a new button, sets the focused object to the previously mentioned button
|
||||||
```lua
|
```lua
|
||||||
local aButton = myFrame:addButton("myFirstButton")
|
local aButton = myFrame:addButton()
|
||||||
myFrame:setFocusedObject(aButton)
|
myFrame:setFocusedObject(aButton)
|
||||||
```
|
```
|
||||||
|
|
||||||
## removeFocusedObject
|
## removeFocusedObject
|
||||||
Removes the focus of the supplied object
|
Removes the focus of the supplied object
|
||||||
|
|
||||||
@@ -167,14 +208,16 @@ Removes the focus of the supplied object
|
|||||||
1. `frame` The frame being used
|
1. `frame` The frame being used
|
||||||
|
|
||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a button with id "myFirstButton", then removes the focus from that button
|
* Creates a new button then removes the focus from that button when clicking on it
|
||||||
```lua
|
```lua
|
||||||
local aButton = myFrame:addButton("myFirstButton")
|
local aButton = myFrame:addButton():setFocus():onClick(function()
|
||||||
myFrame:removeFocusedObject(aButton)
|
myFrame:removeFocusedObject(aButton)
|
||||||
|
end)
|
||||||
```
|
```
|
||||||
|
|
||||||
## getFocusedObject
|
## getFocusedObject
|
||||||
Gets the currently focused object
|
Gets the currently focused object
|
||||||
|
|
||||||
#### Returns:
|
#### Returns:
|
||||||
1. `object` The currently focused object
|
1. `object` The currently focused object
|
||||||
|
|
||||||
@@ -183,9 +226,10 @@ Gets the currently focused object
|
|||||||
```lua
|
```lua
|
||||||
local focusedObject = myFrame:getFocusedObject()
|
local focusedObject = myFrame:getFocusedObject()
|
||||||
```
|
```
|
||||||
## setMovable
|
|
||||||
|
|
||||||
|
## setMovable
|
||||||
Sets whether the frame can be moved. _In order to move the frame click and drag the upper bar of the frame_
|
Sets whether the frame can be moved. _In order to move the frame click and drag the upper bar of the frame_
|
||||||
|
|
||||||
#### Parameters:
|
#### Parameters:
|
||||||
1. `boolean` Whether the object is movable
|
1. `boolean` Whether the object is movable
|
||||||
|
|
||||||
@@ -195,14 +239,18 @@ Sets whether the frame can be moved. _In order to move the frame click and drag
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a frame with id "myFirstFrame" and makes it movable
|
* Creates a frame with id "myFirstFrame" and makes it movable
|
||||||
```lua
|
```lua
|
||||||
local myFrame = basalt.createFrame("myFirstFrame"):setMovable(true)
|
local myFrame = basalt.createFrame():setMovable(true)
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<frame moveable="true"></frame>
|
||||||
```
|
```
|
||||||
|
|
||||||
## setOffset
|
## setOffset
|
||||||
Sets the frame's coordinate offset. The frame's child objects will receive the frame's coordinate offset. For example, when using a scrollbar, if you use its value to add an offset to a frame, you will get a scrollable frame.
|
Sets the frame's coordinate offset. The frame's child objects will receive the frame's coordinate offset. For example, when using a scrollbar, if you use its value to add an offset to a frame, you will get a scrollable frame.
|
||||||
Objects are also able to ignore the offset by using :ignoreOffset() (For example, you may want to ignore the offset on the scrollbar itself)
|
Objects are also able to ignore the offset by using :ignoreOffset() (For example, you may want to ignore the offset on the scrollbar itself)
|
||||||
|
|
||||||
The function can be supplied negative offsets
|
The function can also be supplied with negative values
|
||||||
|
|
||||||
#### Parameters:
|
#### Parameters:
|
||||||
1. `number` The x direction offset (+/-)
|
1. `number` The x direction offset (+/-)
|
||||||
@@ -212,11 +260,163 @@ The function can be supplied negative offsets
|
|||||||
1. `frame` The frame being used
|
1. `frame` The frame being used
|
||||||
|
|
||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates "myFirstFrame" with an x offset of 5 and a y offset of 3
|
* Creates a new base frame with x offset of 5 and a y offset of 3
|
||||||
```lua
|
```lua
|
||||||
local myFrame = basalt.createFrame("myFirstFrame"):setOffset(5, 3)
|
local myFrame = basalt.createFrame():setOffset(5, 3)
|
||||||
```
|
```
|
||||||
* Creates "myFirstFrame" with an x offset of 5 and a y offset of -5 (Meaning if you added a button with y position 5, it would be at y position 0)
|
* Creates with x offset of 5 and a y offset of -5 (Meaning if you added a button with y position 5, it would be at y position 0)
|
||||||
```lua
|
```lua
|
||||||
local myFrame = basalt.createFrame("myFirstFrame"):setOffset(5, -5)
|
local myFrame = basalt.createFrame():setOffset(5, -5)
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<frame xOffset="5" yOffset="-5"></frame>
|
||||||
|
```
|
||||||
|
|
||||||
|
## addLayout
|
||||||
|
Adds a new XML Layout into your frame.
|
||||||
|
|
||||||
|
#### Parameters:
|
||||||
|
1. `string` Path to your layout
|
||||||
|
|
||||||
|
#### Returns:
|
||||||
|
1. `frame` The frame being used
|
||||||
|
|
||||||
|
#### Usage:
|
||||||
|
* Creates a new base frame and adds the mainframe.xml layout
|
||||||
|
```lua
|
||||||
|
local myFrame = basalt.createFrame():addLayout("mainframe.xml")
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<frame layout="mainframe.xml"></frame>
|
||||||
|
```
|
||||||
|
|
||||||
|
## addLayoutFromString
|
||||||
|
Adds a new XML Layout as string into your frame.
|
||||||
|
|
||||||
|
#### Parameters:
|
||||||
|
1. `string` xml
|
||||||
|
|
||||||
|
#### Returns:
|
||||||
|
1. `frame` The frame being used
|
||||||
|
|
||||||
|
#### Usage:
|
||||||
|
* Creates a new base frame and adds the mainframe.xml layout
|
||||||
|
```lua
|
||||||
|
local myFrame = basalt.createFrame():addLayoutFromString("<button x='12' y='5' bg='black' />")
|
||||||
|
```
|
||||||
|
|
||||||
|
## getLastLayout
|
||||||
|
returns a table of all objects this frame has created via xml (useful if you'd like to access all of them for some reason)
|
||||||
|
|
||||||
|
#### Returns:
|
||||||
|
1. `table` table with objects
|
||||||
|
|
||||||
|
## setTheme
|
||||||
|
Sets the default theme of that frame children objects always try to get the theme of its parent frame, if it does not exist it goes to its parent parent frame, and so on until it reaches the basalt managers theme - which is sotred in theme.lua (Please checkout [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for how it could look like.
|
||||||
|
|
||||||
|
#### Parameters:
|
||||||
|
1. `table` theme layout look into [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for a example
|
||||||
|
|
||||||
|
#### Returns:
|
||||||
|
1. `frame` The frame being used
|
||||||
|
|
||||||
|
#### Usage:
|
||||||
|
* Creates a new base frame and adds a new theme which only changes the default color of buttons.
|
||||||
|
```lua
|
||||||
|
local myFrame = basalt.createFrame():setTheme({
|
||||||
|
ButtonBG = colors.yellow,
|
||||||
|
ButtonText = colors.red,
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
## setScrollable
|
||||||
|
Makes the frame scrollable with mousewheel.
|
||||||
|
|
||||||
|
#### Parameters:
|
||||||
|
1. `bool` scrollable or not
|
||||||
|
|
||||||
|
#### Returns:
|
||||||
|
1. `frame` The frame being used
|
||||||
|
|
||||||
|
#### Usage:
|
||||||
|
* Creates a new base frame and makes it scrollable
|
||||||
|
```lua
|
||||||
|
local myFrame = basalt.createFrame():setScrollable()
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<frame scrollable="true"></frame>
|
||||||
|
```
|
||||||
|
|
||||||
|
## setMinScroll
|
||||||
|
Sets the minimum offset it is allowed to scroll (default 0)
|
||||||
|
|
||||||
|
#### Parameters:
|
||||||
|
1. `number` minimum y offset
|
||||||
|
|
||||||
|
#### Returns:
|
||||||
|
1. `frame` The frame being used
|
||||||
|
|
||||||
|
#### Usage:
|
||||||
|
* Creates a new base frame and makes it scrollable and sets the minimum amount to -5
|
||||||
|
```lua
|
||||||
|
local myFrame = basalt.createFrame():setScrollable():setMinScroll(-5)
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<frame minScroll="-5"></frame>
|
||||||
|
```
|
||||||
|
|
||||||
|
## setMaxScroll
|
||||||
|
Sets the maximum offset it is allowed to scroll (default 10)
|
||||||
|
|
||||||
|
#### Parameters:
|
||||||
|
1. `number` maximum y offset
|
||||||
|
|
||||||
|
#### Returns:
|
||||||
|
1. `frame` The frame being used
|
||||||
|
|
||||||
|
#### Usage:
|
||||||
|
* Creates a new base frame and makes it scrollable and sets the maximum amount to 25
|
||||||
|
```lua
|
||||||
|
local myFrame = basalt.createFrame():setScrollable():setMaxScroll(25)
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<frame maxScroll="25"></frame>
|
||||||
|
```
|
||||||
|
|
||||||
|
## setImportantScroll
|
||||||
|
By default if you hovering your mouse over children objects, you wont scroll the frame, if you set this to true the frame scrolling becomes more important
|
||||||
|
|
||||||
|
#### Parameters:
|
||||||
|
1. `bool` important or not
|
||||||
|
|
||||||
|
#### Returns:
|
||||||
|
1. `frame` The frame being used
|
||||||
|
|
||||||
|
#### Usage:
|
||||||
|
* Creates a new base frame and makes it scrollable and defines it as important
|
||||||
|
```lua
|
||||||
|
local myFrame = basalt.createFrame():setScrollable():setImportantScroll(true)
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<frame importantScroll="true"></frame>
|
||||||
|
```
|
||||||
|
|
||||||
|
# XML
|
||||||
|
|
||||||
|
* A fully working example:
|
||||||
|
```xml
|
||||||
|
<frame>
|
||||||
|
<frame width="50%" bg="red">
|
||||||
|
<button x="2" y="2" width="17" text="Example Button!"/>
|
||||||
|
</frame>
|
||||||
|
<frame x="50%+1" width="50%+1" bg="black">
|
||||||
|
<textfield bg="green" x="2" width="100%-2" />
|
||||||
|
</frame>
|
||||||
|
</frame>
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -17,8 +17,12 @@ loads a default .nfp file into the object.
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default image and loads a test.nfp file
|
* Creates a default image and loads a test.nfp file
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame():show()
|
||||||
local aImage = mainFrame:addImage("myFirstImage"):loadImage("test.nfp"):show()
|
local aImage = mainFrame:addImage():loadImage("test.nfp")
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<image path="test.nfp" />
|
||||||
```
|
```
|
||||||
|
|
||||||
## shrink
|
## shrink
|
||||||
@@ -30,6 +34,10 @@ Shrinks the current image into a blittle image.
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default image and loads a test.nfp file
|
* Creates a default image and loads a test.nfp file
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aImage = mainFrame:addImage("myFirstImage"):loadImage("test.nfp"):shrink():show()
|
local aImage = mainFrame:addImage():loadImage("test.nfp"):shrink()
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<image path="test.nfp" shrink="true" />
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -15,8 +15,12 @@ Changes the input type. default: text
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default input and sets it to numbers only.
|
* Creates a default input and sets it to numbers only.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aInput = mainFrame:addInput("myFirstInput"):setInputType("number"):show()
|
local aInput = mainFrame:addInput():setInputType("number")
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<input type="number" />
|
||||||
```
|
```
|
||||||
|
|
||||||
## getInputType
|
## getInputType
|
||||||
@@ -28,8 +32,8 @@ Gets the current input type
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default input and sets it to numbers only. Also prints the current input type to log.
|
* Creates a default input and sets it to numbers only. Also prints the current input type to log.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aInput = mainFrame:addInput("myFirstInput"):setInputType("number"):show()
|
local aInput = mainFrame:addInput():setInputType("number")
|
||||||
basalt.debug(aInput:getInputType())
|
basalt.debug(aInput:getInputType())
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -47,8 +51,12 @@ Sets the default text. This will only be displayed if there is no input set by t
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default input and sets the default text to "...".
|
* Creates a default input and sets the default text to "...".
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aInput = mainFrame:addInput("myFirstInput"):setInputType("number"):setDefaultText(...):show()
|
local aInput = mainFrame:addInput():setDefaultText("...")
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<input default="..." />
|
||||||
```
|
```
|
||||||
|
|
||||||
## setInputLimit
|
## setInputLimit
|
||||||
@@ -63,8 +71,12 @@ Sets a character limit to the input.
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default input and sets the character limit to 8.
|
* Creates a default input and sets the character limit to 8.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aInput = mainFrame:addInput("myFirstInput"):setInputLimit(8):show()
|
local aInput = mainFrame:addInput():setInputLimit(8)
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<input limit="8" />
|
||||||
```
|
```
|
||||||
|
|
||||||
## getInputLimit
|
## getInputLimit
|
||||||
@@ -76,7 +88,7 @@ Returns the input limit.
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default input and sets the character limit to 8. Prints the current limit.
|
* Creates a default input and sets the character limit to 8. Prints the current limit.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aInput = mainFrame:addInput("myFirstInput"):setInputLimit(8):show()
|
local aInput = mainFrame:addInput():setInputLimit(8)
|
||||||
basalt.debug(aInput:getInputLimit())
|
basalt.debug(aInput:getInputLimit())
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
|||||||
local aLabel = mainFrame:addLabel("myFirstLabel"):setText("Some random text"):show()
|
local aLabel = mainFrame:addLabel("myFirstLabel"):setText("Some random text"):show()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<label text="Some random text" />
|
||||||
|
```
|
||||||
|
|
||||||
## setFontSize
|
## setFontSize
|
||||||
Sets the font size, calculated by bigfonts. Default size is 1.
|
Sets the font size, calculated by bigfonts. Default size is 1.
|
||||||
|
|
||||||
@@ -39,6 +43,10 @@ local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
|||||||
local aLabel = mainFrame:addLabel("myFirstLabel"):setText("Basalt!"):setFontSize(2):show()
|
local aLabel = mainFrame:addLabel("myFirstLabel"):setText("Basalt!"):setFontSize(2):show()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<label font="2" />
|
||||||
|
```
|
||||||
|
|
||||||
## getFontSize
|
## getFontSize
|
||||||
Returns the current font size
|
Returns the current font size
|
||||||
|
|
||||||
@@ -52,3 +60,21 @@ local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
|||||||
local aLabel = mainFrame:addLabel("myFirstLabel"):setText("Basalt!"):setFontSize(2):show()
|
local aLabel = mainFrame:addLabel("myFirstLabel"):setText("Basalt!"):setFontSize(2):show()
|
||||||
basalt.debug(aLabel:getFontSize())
|
basalt.debug(aLabel:getFontSize())
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## setTextAlign
|
||||||
|
Changes the text align
|
||||||
|
|
||||||
|
#### Returns:
|
||||||
|
1. `string` horizontal ("left", "center", "right")
|
||||||
|
1. `string` vertical ("top", "center", "bottom")
|
||||||
|
|
||||||
|
#### Usage:
|
||||||
|
* Creates a default label, sets the text to "Basalt!" changes the horizontal align to right
|
||||||
|
```lua
|
||||||
|
local mainFrame = basalt.createFrame()
|
||||||
|
local aLabel = mainFrame:addLabel():setText("Basalt!"):setTextAlign("right")
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<label horizontalAlign="right" verticalAlign="center" />
|
||||||
|
```
|
||||||
|
|||||||
@@ -28,13 +28,21 @@ Adds a item into the menubar
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default menubar with 3 entries
|
* Creates a default menubar with 3 entries
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
|
local aMenubar = mainFrame:addMenubar()
|
||||||
aMenubar:addItem("1. Entry")
|
aMenubar:addItem("1. Entry")
|
||||||
aMenubar:addItem("2. Entry",colors.yellow)
|
aMenubar:addItem("2. Entry",colors.yellow)
|
||||||
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<menubar>
|
||||||
|
<item><text>1. Entry</text></item>
|
||||||
|
<item><text>2. Entry</text><bg>yellow</bg></item>
|
||||||
|
<item><text>3. Entry</text><bg>yellow</bg><fg>green</fg></item>
|
||||||
|
</menubar>
|
||||||
|
```
|
||||||
|
|
||||||
## removeItem
|
## removeItem
|
||||||
Removes a item from the menubar
|
Removes a item from the menubar
|
||||||
|
|
||||||
@@ -47,8 +55,8 @@ Removes a item from the menubar
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default menubar with 3 entries and removes the second one.
|
* Creates a default menubar with 3 entries and removes the second one.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
|
local aMenubar = mainFrame:addMenubar()
|
||||||
aMenubar:addItem("1. Entry")
|
aMenubar:addItem("1. Entry")
|
||||||
aMenubar:addItem("2. Entry",colors.yellow)
|
aMenubar:addItem("2. Entry",colors.yellow)
|
||||||
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
||||||
@@ -71,8 +79,8 @@ Edits a item from the menubar
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default menubar with 3 entries and edits the second one.
|
* Creates a default menubar with 3 entries and edits the second one.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
|
local aMenubar = mainFrame:addMenubar()
|
||||||
aMenubar:addItem("1. Entry")
|
aMenubar:addItem("1. Entry")
|
||||||
aMenubar:addItem("2. Entry",colors.yellow)
|
aMenubar:addItem("2. Entry",colors.yellow)
|
||||||
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
||||||
@@ -91,8 +99,8 @@ Returns a item by index
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default menubar with 3 entries and edits the second one.
|
* Creates a default menubar with 3 entries and edits the second one.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
|
local aMenubar = mainFrame:addMenubar()
|
||||||
aMenubar:addItem("1. Entry")
|
aMenubar:addItem("1. Entry")
|
||||||
aMenubar:addItem("2. Entry",colors.yellow)
|
aMenubar:addItem("2. Entry",colors.yellow)
|
||||||
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
||||||
@@ -108,8 +116,8 @@ Returns the current item count
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default menubar with 3 entries and prints the current item count.
|
* Creates a default menubar with 3 entries and prints the current item count.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
|
local aMenubar = mainFrame:addMenubar()
|
||||||
aMenubar:addItem("1. Entry")
|
aMenubar:addItem("1. Entry")
|
||||||
aMenubar:addItem("2. Entry",colors.yellow)
|
aMenubar:addItem("2. Entry",colors.yellow)
|
||||||
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
||||||
@@ -125,8 +133,8 @@ Returns all items as table
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default menubar with 3 entries and prints a table.
|
* Creates a default menubar with 3 entries and prints a table.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
|
local aMenubar = mainFrame:addMenubar()
|
||||||
aMenubar:addItem("1. Entry")
|
aMenubar:addItem("1. Entry")
|
||||||
aMenubar:addItem("2. Entry",colors.yellow)
|
aMenubar:addItem("2. Entry",colors.yellow)
|
||||||
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
||||||
@@ -145,14 +153,22 @@ Sets the space between entries
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default menubar with 3 entries and changes the space to 3.
|
* Creates a default menubar with 3 entries and changes the space to 3.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
|
local aMenubar = mainFrame:addMenubar()
|
||||||
aMenubar:addItem("1. Entry")
|
aMenubar:addItem("1. Entry")
|
||||||
aMenubar:addItem("2. Entry",colors.yellow)
|
aMenubar:addItem("2. Entry",colors.yellow)
|
||||||
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
||||||
aMenubar:setSpace(3)
|
aMenubar:setSpace(3)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<menubar space="3">
|
||||||
|
<item><text>1. Entry</text></item>
|
||||||
|
<item><text>2. Entry</text><bg>yellow</bg></item>
|
||||||
|
<item><text>3. Entry</text><bg>yellow</bg><fg>green</fg></item>
|
||||||
|
</menubar>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## setScrollable
|
## setScrollable
|
||||||
@@ -167,14 +183,22 @@ Makes the menubar scrollable. The menubar will be scrollable as soon as the menu
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default menubar with 3 entries and makes it scrollable.
|
* Creates a default menubar with 3 entries and makes it scrollable.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
|
local aMenubar = mainFrame:addMenubar()
|
||||||
aMenubar:addItem("1. Entry")
|
aMenubar:addItem("1. Entry")
|
||||||
aMenubar:addItem("2. Entry",colors.yellow)
|
aMenubar:addItem("2. Entry",colors.yellow)
|
||||||
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
||||||
aMenubar:setScrollable(true)
|
aMenubar:setScrollable(true)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<menubar scrollable="true">
|
||||||
|
<item><text>1. Entry</text></item>
|
||||||
|
<item><text>2. Entry</text><bg>yellow</bg></item>
|
||||||
|
<item><text>3. Entry</text><bg>yellow</bg><fg>green</fg></item>
|
||||||
|
</menubar>
|
||||||
|
```
|
||||||
|
|
||||||
## selectItem
|
## selectItem
|
||||||
selects a item in the list (same as a player would click on a item)
|
selects a item in the list (same as a player would click on a item)
|
||||||
|
|
||||||
@@ -187,8 +211,8 @@ selects a item in the list (same as a player would click on a item)
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default menubar with 3 entries and selects the second entry.
|
* Creates a default menubar with 3 entries and selects the second entry.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
|
local aMenubar = mainFrame:addMenubar()
|
||||||
aMenubar:addItem("1. Entry")
|
aMenubar:addItem("1. Entry")
|
||||||
aMenubar:addItem("2. Entry",colors.yellow)
|
aMenubar:addItem("2. Entry",colors.yellow)
|
||||||
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
||||||
@@ -205,8 +229,8 @@ Removes all items.
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default menubar with 3 entries and removes them immediatley. Which makes no sense.
|
* Creates a default menubar with 3 entries and removes them immediatley. Which makes no sense.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
|
local aMenubar = mainFrame:addMenubar()
|
||||||
aMenubar:addItem("1. Entry")
|
aMenubar:addItem("1. Entry")
|
||||||
aMenubar:addItem("2. Entry",colors.yellow)
|
aMenubar:addItem("2. Entry",colors.yellow)
|
||||||
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
||||||
@@ -222,8 +246,8 @@ returns the item index of the currently selected item
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default menubar with 3 entries selects the second entry and prints the currently selected index.
|
* Creates a default menubar with 3 entries selects the second entry and prints the currently selected index.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
|
local aMenubar = mainFrame:addMenubar()
|
||||||
aMenubar:addItem("1. Entry")
|
aMenubar:addItem("1. Entry")
|
||||||
aMenubar:addItem("2. Entry",colors.yellow)
|
aMenubar:addItem("2. Entry",colors.yellow)
|
||||||
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
aMenubar:addItem("3. Entry",colors.yellow,colors.green)
|
||||||
@@ -244,16 +268,25 @@ Sets the background and the foreground of the item which is currently selected
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default menubar with 4 entries and sets the selection background color to green.
|
* Creates a default menubar with 4 entries and sets the selection background color to green.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
|
local aMenubar = mainFrame:addMenubar()
|
||||||
aMenubar:addItem("1. Entry")
|
aMenubar:addItem("1. Entry")
|
||||||
aMenubar:addItem("2. Entry")
|
aMenubar:addItem("2. Entry")
|
||||||
aMenubar:addItem("3. Entry")
|
aMenubar:addItem("3. Entry")
|
||||||
aMenubar:addItem("4. Entry")
|
aMenubar:addItem("4. Entry")
|
||||||
aMenubar:setSelectedItem(colors.green)
|
aMenubar:setSelectedItem(colors.green, colors.yellow)
|
||||||
```
|
```
|
||||||
|
|
||||||
## setPositionOffset
|
```xml
|
||||||
|
<menubar selectionBG="green" selectionFG="yellow">
|
||||||
|
<item><text>1. Entry</text></item>
|
||||||
|
<item><text>2. Entry</text></item>
|
||||||
|
<item><text>3. Entry</text></item>
|
||||||
|
<item><text>4. Entry</text></item>
|
||||||
|
</menubar>
|
||||||
|
```
|
||||||
|
|
||||||
|
## setOffset
|
||||||
Sets the offset of the menubar (the same as you would scroll) - default is 0
|
Sets the offset of the menubar (the same as you would scroll) - default is 0
|
||||||
|
|
||||||
#### Parameters:
|
#### Parameters:
|
||||||
@@ -265,18 +298,29 @@ Sets the offset of the menubar (the same as you would scroll) - default is 0
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default menubar with 6 entries and sets the offset to 3.
|
* Creates a default menubar with 6 entries and sets the offset to 3.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
|
local aMenubar = mainFrame:addMenubar()
|
||||||
aMenubar:addItem("1. Entry")
|
aMenubar:addItem("1. Entry")
|
||||||
aMenubar:addItem("2. Entry")
|
aMenubar:addItem("2. Entry")
|
||||||
aMenubar:addItem("3. Entry")
|
aMenubar:addItem("3. Entry")
|
||||||
aMenubar:addItem("4. Entry")
|
aMenubar:addItem("4. Entry")
|
||||||
aMenubar:addItem("5. Entry")
|
aMenubar:addItem("5. Entry")
|
||||||
aMenubar:addItem("6. Entry")
|
aMenubar:addItem("6. Entry")
|
||||||
aMenubar:setPositionOffset(3)
|
aMenubar:setOffset(3)
|
||||||
```
|
```
|
||||||
|
|
||||||
## getPositionOffset
|
```xml
|
||||||
|
<menubar offset="3">
|
||||||
|
<item><text>1. Entry</text></item>
|
||||||
|
<item><text>2. Entry</text></item>
|
||||||
|
<item><text>3. Entry</text></item>
|
||||||
|
<item><text>4. Entry</text></item>
|
||||||
|
<item><text>5. Entry</text></item>
|
||||||
|
<item><text>6. Entry</text></item>
|
||||||
|
</menubar>
|
||||||
|
```
|
||||||
|
|
||||||
|
## getOffset
|
||||||
returns the current offset
|
returns the current offset
|
||||||
|
|
||||||
#### Returns:
|
#### Returns:
|
||||||
@@ -285,14 +329,14 @@ returns the current offset
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a default menubar with 6 entries and sets the offset to 3, prints the current offset.
|
* Creates a default menubar with 6 entries and sets the offset to 3, prints the current offset.
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aMenubar = mainFrame:addMenubar("myFirstMenubar"):show()
|
local aMenubar = mainFrame:addMenubar()
|
||||||
aMenubar:addItem("1. Entry")
|
aMenubar:addItem("1. Entry")
|
||||||
aMenubar:addItem("2. Entry")
|
aMenubar:addItem("2. Entry")
|
||||||
aMenubar:addItem("3. Entry")
|
aMenubar:addItem("3. Entry")
|
||||||
aMenubar:addItem("4. Entry")
|
aMenubar:addItem("4. Entry")
|
||||||
aMenubar:addItem("5. Entry")
|
aMenubar:addItem("5. Entry")
|
||||||
aMenubar:addItem("6. Entry")
|
aMenubar:addItem("6. Entry")
|
||||||
aMenubar:setPositionOffset(3)
|
aMenubar:getOffset(3)
|
||||||
basalt.debug(aMenubar:getPositionOffset())
|
basalt.debug(aMenubar:getOffset())
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -13,6 +13,11 @@ local button = mainFrame:addButton("myFirstButton")
|
|||||||
button:show()
|
button:show()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### XML:
|
||||||
|
```xml
|
||||||
|
<button visible="true"></button>
|
||||||
|
```
|
||||||
|
|
||||||
## hide
|
## hide
|
||||||
Hides the object
|
Hides the object
|
||||||
|
|
||||||
@@ -27,6 +32,11 @@ local button = mainFrame:addButton("myFirstButton"):setText("Close"):onClick(fun
|
|||||||
button:show()
|
button:show()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### XML:
|
||||||
|
```xml
|
||||||
|
<button visible="false"></button>
|
||||||
|
```
|
||||||
|
|
||||||
## setPosition
|
## setPosition
|
||||||
Changes the position relative to its parent frame
|
Changes the position relative to its parent frame
|
||||||
#### Parameters:
|
#### Parameters:
|
||||||
@@ -44,6 +54,11 @@ local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
|||||||
mainFrame:addButton("myFirstButton"):setPosition(2,3)
|
mainFrame:addButton("myFirstButton"):setPosition(2,3)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### XML:
|
||||||
|
```xml
|
||||||
|
<button x="2" y="3"></button>
|
||||||
|
```
|
||||||
|
|
||||||
## setBackground
|
## setBackground
|
||||||
Changes the object background color, if you set the value to false the background wont be visible. For example you could see trough a frame.
|
Changes the object background color, if you set the value to false the background wont be visible. For example you could see trough a frame.
|
||||||
#### Parameters:
|
#### Parameters:
|
||||||
@@ -58,6 +73,11 @@ Changes the object background color, if you set the value to false the backgroun
|
|||||||
local mainFrame = basalt.createFrame("myFirstFrame"):setBackground(colors.gray)
|
local mainFrame = basalt.createFrame("myFirstFrame"):setBackground(colors.gray)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### XML:
|
||||||
|
```xml
|
||||||
|
<button bg="gray"></button>
|
||||||
|
```
|
||||||
|
|
||||||
## setForeground
|
## setForeground
|
||||||
Changes the object text color
|
Changes the object text color
|
||||||
#### Parameters:
|
#### Parameters:
|
||||||
@@ -72,6 +92,11 @@ Changes the object text color
|
|||||||
local mainFrame = basalt.createFrame("myFirstFrame"):setForeground(colors.green)
|
local mainFrame = basalt.createFrame("myFirstFrame"):setForeground(colors.green)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### XML:
|
||||||
|
```xml
|
||||||
|
<button fg="green"></button>
|
||||||
|
```
|
||||||
|
|
||||||
## setSize
|
## setSize
|
||||||
Changes the object size
|
Changes the object size
|
||||||
#### Parameters:
|
#### Parameters:
|
||||||
@@ -88,6 +113,11 @@ local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
|||||||
local subFrame = mainFrame:addFrame("myFirstSubFrame"):setSize(15,12):show()
|
local subFrame = mainFrame:addFrame("myFirstSubFrame"):setSize(15,12):show()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### XML:
|
||||||
|
```xml
|
||||||
|
<frame width="15" height="12"></frame>
|
||||||
|
```
|
||||||
|
|
||||||
## setFocus
|
## setFocus
|
||||||
Sets the object to be the focused object.
|
Sets the object to be the focused object.
|
||||||
If you click on an object, it's normally automatically the focused object. For example, if you call :show() on a frame, and you want this particular frame to be in
|
If you click on an object, it's normally automatically the focused object. For example, if you call :show() on a frame, and you want this particular frame to be in
|
||||||
@@ -118,6 +148,12 @@ local aButton = mainFrame:addButton("myFirstButton"):setZIndex(1):setPosition(2,
|
|||||||
local aLabel = mainFrame:addButton("myFirstLabel"):setZIndex(2):setPosition(2,2):setText("I am a label!"):show()
|
local aLabel = mainFrame:addButton("myFirstLabel"):setZIndex(2):setPosition(2,2):setText("I am a label!"):show()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### XML:
|
||||||
|
```xml
|
||||||
|
<button x="2" y="2" zIndex="1"></button>
|
||||||
|
<label x="2" y="2" text="I am a label!" zIndex="2"></label>
|
||||||
|
```
|
||||||
|
|
||||||
## setParent
|
## setParent
|
||||||
Sets the parent frame of the object
|
Sets the parent frame of the object
|
||||||
#### Parameters:
|
#### Parameters:
|
||||||
@@ -195,6 +231,11 @@ local aButton = mainFrame:addButton("myFirstButton")
|
|||||||
:show()
|
:show()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### XML:
|
||||||
|
```xml
|
||||||
|
<button anchor="bottomRight"></button>
|
||||||
|
```
|
||||||
|
|
||||||
## getAbsolutePosition
|
## getAbsolutePosition
|
||||||
Converts the relative coordinates into absolute coordinates
|
Converts the relative coordinates into absolute coordinates
|
||||||
#### Parameters:
|
#### Parameters:
|
||||||
@@ -212,26 +253,6 @@ local aButton = mainFrame:addButton("myFirstButton"):setSize(8,1):setPosition(4,
|
|||||||
basalt.debug(aButton:getAbsolutePosition()) -- returns 7,5 (frame coords + own coords) instead of 4,2
|
basalt.debug(aButton:getAbsolutePosition()) -- returns 7,5 (frame coords + own coords) instead of 4,2
|
||||||
```
|
```
|
||||||
|
|
||||||
## setTextAlign
|
|
||||||
Sets the text align of the object (for example buttons)
|
|
||||||
#### Parameters:
|
|
||||||
1. `string` horizontal
|
|
||||||
2. `string` vertical ("left", "center", "right")
|
|
||||||
|
|
||||||
#### Returns:
|
|
||||||
1. `object` The object in use
|
|
||||||
|
|
||||||
#### Usage:
|
|
||||||
* Creates a button with text aligned to `right, center`
|
|
||||||
```lua
|
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
|
||||||
local aButton = mainFrame:addButton("myFirstButton")
|
|
||||||
:setSize(12,3)
|
|
||||||
:setTextAlign("right", "center")
|
|
||||||
:setText("Don't...")
|
|
||||||
:show()
|
|
||||||
```
|
|
||||||
|
|
||||||
## setValue
|
## setValue
|
||||||
Sets the value of that object (input, label, checkbox, textfield, scrollbar,...)
|
Sets the value of that object (input, label, checkbox, textfield, scrollbar,...)
|
||||||
#### Parameters:
|
#### Parameters:
|
||||||
@@ -247,6 +268,11 @@ local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
|||||||
local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):setValue(true):show()
|
local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):setValue(true):show()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### XML:
|
||||||
|
```xml
|
||||||
|
<checkbox value="true"></checkbox>
|
||||||
|
```
|
||||||
|
|
||||||
## getValue
|
## getValue
|
||||||
Returns the currently saved value
|
Returns the currently saved value
|
||||||
#### Returns:
|
#### Returns:
|
||||||
@@ -317,7 +343,11 @@ local subFrame = mainFrame:addFrame("mySubFrame")
|
|||||||
:setSize(18,6)
|
:setSize(18,6)
|
||||||
:setShadow(colors.green)
|
:setShadow(colors.green)
|
||||||
:showShadow(true)
|
:showShadow(true)
|
||||||
:show()
|
```
|
||||||
|
|
||||||
|
#### XML:
|
||||||
|
```xml
|
||||||
|
<frame width="18" height="6" shadow="true" shadowColor="green" moveable="true"></frame>
|
||||||
```
|
```
|
||||||
|
|
||||||
## showShadow
|
## showShadow
|
||||||
@@ -332,14 +362,19 @@ Shows or hides the shadow
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Shows the shadow:
|
* Shows the shadow:
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame():show()
|
||||||
local subFrame = mainFrame:addFrame("mySubFrame")
|
local subFrame = mainFrame:addFrame()
|
||||||
:setMoveable()
|
:setMoveable()
|
||||||
:setSize(18,6)
|
:setSize(18,6)
|
||||||
:showShadow(true)
|
:showShadow(true)
|
||||||
:show()
|
:show()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### XML:
|
||||||
|
```xml
|
||||||
|
<frame width="18" height="6" shadow="true" moveable="true"></frame>
|
||||||
|
```
|
||||||
|
|
||||||
## setBorder
|
## setBorder
|
||||||
Sets the border color - default: colors.black
|
Sets the border color - default: colors.black
|
||||||
|
|
||||||
@@ -361,6 +396,11 @@ local subFrame = mainFrame:addFrame("mySubFrame")
|
|||||||
:show()
|
:show()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### XML:
|
||||||
|
```xml
|
||||||
|
<frame width="18" height="6" border="true" borderColor="green" moveable="true"></frame>
|
||||||
|
```
|
||||||
|
|
||||||
## showBorder
|
## showBorder
|
||||||
Shows or hides the border
|
Shows or hides the border
|
||||||
|
|
||||||
@@ -377,6 +417,11 @@ local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
|||||||
local subFrame = mainFrame:addFrame("mySubFrame")
|
local subFrame = mainFrame:addFrame("mySubFrame")
|
||||||
:setMoveable()
|
:setMoveable()
|
||||||
:setSize(18,6)
|
:setSize(18,6)
|
||||||
:showBorder("left", "top", "right", "bottom")
|
:showBorder("left", "top", "bottom")
|
||||||
:show()
|
:show()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### XML:
|
||||||
|
```xml
|
||||||
|
<frame width="18" height="6" border="true" borderColor="green" borderRight="false" moveable="true"></frame>
|
||||||
|
```
|
||||||
@@ -8,9 +8,13 @@ Pane doesn't have any custom functionallity. If you want to change the color/pos
|
|||||||
## Example:
|
## Example:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aPane = mainFrame:addPane("myFirstBackground")
|
local aPane = mainFrame:addPane()
|
||||||
aPane:setSize(30, 10)
|
aPane:setSize(30, 10)
|
||||||
aPane:setBackground(colors.yellow)
|
aPane:setBackground(colors.yellow)
|
||||||
aPane:show()
|
aPane:show()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<pane width="30" height="10" bg="yellow" />
|
||||||
|
```
|
||||||
@@ -35,6 +35,11 @@ local aProgram = mainFrame:addProgram("myFirstProgram"):show()
|
|||||||
aProgram:execute("rom/programs/fun/worm.lua") -- executes worm
|
aProgram:execute("rom/programs/fun/worm.lua") -- executes worm
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### XML:
|
||||||
|
```xml
|
||||||
|
<program path="rom/programs/fun/worm.lua" execute="true" />
|
||||||
|
```
|
||||||
|
|
||||||
## stop
|
## stop
|
||||||
Stops a currently running program
|
Stops a currently running program
|
||||||
|
|
||||||
|
|||||||
@@ -15,11 +15,15 @@ Sets the direction in which the bar should be expanding.
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a progressbar and sets the direction from bottom to top
|
* Creates a progressbar and sets the direction from bottom to top
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame():show()
|
||||||
local aProgressbar = mainFrame:addProgressbar("myFirstProgressbar"):show()
|
local aProgressbar = mainFrame:addProgressbar():show()
|
||||||
aProgressbar:setDirection(3)
|
aProgressbar:setDirection(3)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<frame direction="3"></frame>
|
||||||
|
```
|
||||||
|
|
||||||
## setProgress
|
## setProgress
|
||||||
This is the function you need to call if you want the progression to change.
|
This is the function you need to call if you want the progression to change.
|
||||||
|
|
||||||
@@ -32,23 +36,22 @@ This is the function you need to call if you want the progression to change.
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a progressbar and sets the current progress to 50
|
* Creates a progressbar and sets the current progress to 50
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame():show()
|
||||||
local aProgressbar = mainFrame:addProgressbar("myFirstProgressbar"):show()
|
local aProgressbar = mainFrame:addProgressbar():show()
|
||||||
aProgressbar:setProgress(50)
|
aProgressbar:setProgress(50)
|
||||||
```
|
```
|
||||||
|
|
||||||
## getProgress
|
## getProgress
|
||||||
Returns the current progress status
|
Returns the current progress status
|
||||||
|
|
||||||
|
|
||||||
#### Returns:
|
#### Returns:
|
||||||
1. `number` progress (0-100)
|
1. `number` progress (0-100)
|
||||||
|
|
||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a progressbar, sets the current progress to 50 and prints the current progress
|
* Creates a progressbar, sets the current progress to 50 and prints the current progress
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame():show()
|
||||||
local aProgressbar = mainFrame:addProgressbar("myFirstProgressbar"):show()
|
local aProgressbar = mainFrame:addProgressbar():show()
|
||||||
aProgressbar:setProgress(50)
|
aProgressbar:setProgress(50)
|
||||||
basalt.debug(aProgressbar:getProgress())
|
basalt.debug(aProgressbar:getProgress())
|
||||||
```
|
```
|
||||||
@@ -67,9 +70,13 @@ This function will change the visual display of your progress bar
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a progressbar and sets the progressbar color to green
|
* Creates a progressbar and sets the progressbar color to green
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame():show()
|
||||||
local aProgressbar = mainFrame:addProgressbar("myFirstProgressbar"):show()
|
local aProgressbar = mainFrame:addProgressbar():show()
|
||||||
aProgressbar:setProgressBar(colors.green)
|
aProgressbar:setProgressBar(colors.green, colors.yellow, colors.red)
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<progressbar progressColor="green" progressSymbol="yellow" progressSymbolColor="red" />
|
||||||
```
|
```
|
||||||
|
|
||||||
## setBackgroundSymbol
|
## setBackgroundSymbol
|
||||||
@@ -84,11 +91,15 @@ Will change the default background symbol (default is " " - space)
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Creates a progressbar and sets the progressbar background symbol to X
|
* Creates a progressbar and sets the progressbar background symbol to X
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame():show()
|
||||||
local aProgressbar = mainFrame:addProgressbar("myFirstProgressbar"):show()
|
local aProgressbar = mainFrame:addProgressbar():show()
|
||||||
aProgressbar:setBackgroundSymbol("X")
|
aProgressbar:setBackgroundSymbol("X")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<progressbar backgroundSymbol="X" />
|
||||||
|
```
|
||||||
|
|
||||||
# Events
|
# Events
|
||||||
|
|
||||||
# onProgressDone
|
# onProgressDone
|
||||||
@@ -98,13 +109,30 @@ A custom event which gets triggered as soon as the progress reaches 100.
|
|||||||
Here is a example on how to add a onProgressDone event to your progressbar:
|
Here is a example on how to add a onProgressDone event to your progressbar:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local basalt = dofile("basalt.lua")
|
local basalt = require("Basalt")
|
||||||
|
|
||||||
local mainFrame = basalt.createFrame("myMainFrame"):show()
|
local mainFrame = basalt.createFrame():show()
|
||||||
local aProgressbar = mainFrame:addProgressbar("myFirstProgressbar"):show()
|
local aProgressbar = mainFrame:addProgressbar():show()
|
||||||
|
|
||||||
function progressDone()
|
function progressDone()
|
||||||
basalt.debug("The Progressbar reached 100%!")
|
basalt.debug("The Progressbar reached 100%!")
|
||||||
end
|
end
|
||||||
aProgressbar:onProgressDone(progressDone)
|
aProgressbar:onProgressDone(progressDone)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## XML Example
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local basalt = require("Basalt")
|
||||||
|
|
||||||
|
local mainFrame = basalt.createFrame()
|
||||||
|
|
||||||
|
basalt.setVariable("progressDone", function()
|
||||||
|
basalt.debug("The Progressbar reached 100%!")
|
||||||
|
end)
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<progressbar onDone="progressDone" />
|
||||||
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ basalt.debug(aTextfield:editLine(1, "Hello!"))
|
|||||||
Adds a line on index position
|
Adds a line on index position
|
||||||
|
|
||||||
#### Parameteres:
|
#### Parameteres:
|
||||||
1. `number` index
|
1. `string` text
|
||||||
2. `string` text
|
2. `number` index
|
||||||
|
|
||||||
#### Returns:
|
#### Returns:
|
||||||
1. `object` The object in use
|
1. `object` The object in use
|
||||||
@@ -66,7 +66,15 @@ Adds a line on index position
|
|||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
||||||
local aTextfield = mainFrame:addTextfield("myFirstTextfield"):show()
|
local aTextfield = mainFrame:addTextfield("myFirstTextfield"):show()
|
||||||
basalt.debug(aTextfield:addLine(1, "Hello!"))
|
basalt.debug(aTextfield:addLine("Hello!", 1))
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<textfield>
|
||||||
|
<lines>
|
||||||
|
<line>Hello!</line>
|
||||||
|
</lines>
|
||||||
|
</textfield>
|
||||||
```
|
```
|
||||||
|
|
||||||
## removeLine
|
## removeLine
|
||||||
@@ -93,3 +101,64 @@ Gets text cursor position
|
|||||||
#### Returns:
|
#### Returns:
|
||||||
1. `number` x position
|
1. `number` x position
|
||||||
2. `number` y position
|
2. `number` y position
|
||||||
|
|
||||||
|
## addKeywords
|
||||||
|
Adds keywords for special coloring
|
||||||
|
|
||||||
|
#### Parameteres:
|
||||||
|
1. `number|color` color of your choice
|
||||||
|
2. `table` a list of keywords which should be colored example: {"if", "else", "then", "while", "do"}
|
||||||
|
|
||||||
|
#### Returns:
|
||||||
|
1. `object` The object in use
|
||||||
|
|
||||||
|
#### Usage:
|
||||||
|
* Changes the color of some words to purple
|
||||||
|
```lua
|
||||||
|
local mainFrame = basalt.createFrame()
|
||||||
|
local aTextfield = mainFrame:addTextfield():addKeywords(colors.purple, {"if", "else", "then", "while", "do", "hello"})
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<textfield>
|
||||||
|
<keywords>
|
||||||
|
<purple>
|
||||||
|
<keyword>if</keyword>
|
||||||
|
<keyword>else</keyword>
|
||||||
|
<keyword>then</keyword>
|
||||||
|
<keyword>while</keyword>
|
||||||
|
<keyword>do</keyword>
|
||||||
|
<keyword>hello</keyword>
|
||||||
|
</purple>
|
||||||
|
</keywords>
|
||||||
|
</textfield>
|
||||||
|
```
|
||||||
|
|
||||||
|
## addRule
|
||||||
|
Adds a new rule for special coloring
|
||||||
|
|
||||||
|
#### Parameteres:
|
||||||
|
1. `string` a pattern - check out this page: (https://riptutorial.com/lua/example/20315/lua-pattern-matching)
|
||||||
|
2. `number|color` text color
|
||||||
|
3. `number|color` background color - optional
|
||||||
|
|
||||||
|
#### Returns:
|
||||||
|
1. `object` The object in use
|
||||||
|
|
||||||
|
#### Usage:
|
||||||
|
* Changes the color of all numbers
|
||||||
|
```lua
|
||||||
|
local mainFrame = basalt.createFrame()
|
||||||
|
local aTextfield = mainFrame:addTextfield():addRule("%d", colors.lightBlue)
|
||||||
|
```
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<textfield>
|
||||||
|
<rules>
|
||||||
|
<rule>
|
||||||
|
<pattern>%d</pattern>
|
||||||
|
<fg>lightBlue</fg>
|
||||||
|
</rule>
|
||||||
|
</rules>
|
||||||
|
</textfield>
|
||||||
|
```
|
||||||
@@ -12,8 +12,8 @@ starts a new thread and executes the function
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Starts a new thread
|
* Starts a new thread
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aThread = mainFrame:addThread("myFirstThread"):show()
|
local aThread = mainFrame:addThread()
|
||||||
local function randomThreadFunction()
|
local function randomThreadFunction()
|
||||||
while true do
|
while true do
|
||||||
basalt.debug("Thread is active")
|
basalt.debug("Thread is active")
|
||||||
@@ -21,6 +21,14 @@ local function randomThreadFunction()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
aThread:start(randomThreadfunction)
|
aThread:start(randomThreadfunction)
|
||||||
|
```
|
||||||
|
```lua
|
||||||
|
basalt.setVariable("myThread", function() while true do os.sleep(1) end end)
|
||||||
|
|
||||||
|
```
|
||||||
|
```xml
|
||||||
|
<thread thread="myThread" start="true"/>
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## stop
|
## stop
|
||||||
@@ -32,8 +40,8 @@ stops the thread
|
|||||||
#### Usage:
|
#### Usage:
|
||||||
* Stops the current running thread by clicking on a button
|
* Stops the current running thread by clicking on a button
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aThread = mainFrame:addThread("myFirstThread"):show()
|
local aThread = mainFrame:addThread()
|
||||||
local function randomThreadFunction()
|
local function randomThreadFunction()
|
||||||
while true do
|
while true do
|
||||||
basalt.debug("Thread is active")
|
basalt.debug("Thread is active")
|
||||||
@@ -41,7 +49,7 @@ local function randomThreadFunction()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
aThread:start(randomThreadfunction)
|
aThread:start(randomThreadfunction)
|
||||||
local aButton = mainFrame:addButton("myFirstButton"):setText("Stop Thread"):onClick(function() aThread:stop() end):show()
|
local aButton = mainFrame:addButton():setText("Stop Thread"):onClick(function() aThread:stop() end)
|
||||||
```
|
```
|
||||||
|
|
||||||
## getStatus
|
## getStatus
|
||||||
@@ -52,7 +60,7 @@ gets the current thread status
|
|||||||
|
|
||||||
#### Usage:
|
#### Usage:
|
||||||
```lua
|
```lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame()
|
||||||
local aThread = mainFrame:addThread("myFirstThread"):show()
|
local aThread = mainFrame:addThread()
|
||||||
basalt.debug(aThread:getStatus())
|
basalt.debug(aThread:getStatus())
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user