pyroxenium / basalt Goto Github PK
View Code? Open in Web Editor NEWA UI Framework for CC:Tweaked
License: MIT License
A UI Framework for CC:Tweaked
License: MIT License
It seems like basalt.autoUpdate()
does not return true errors upon failure. Instead, it prints the error itself, and returns normally. This causes some things that depend on true errors to fail, such as pcall
or xpcall
.
This effectively makes implementing custom backtraces for basalt impossible. As a real example of this, running basalt inside of mbs will not print the backtrace, as mbs expects the program to raise an actual error
upon failure.
The main usage I have for this is to log the backtrace:
--- ...
local function log_traceback()
utils.log(debug.traceback())
end
utils.log('Running main loop')
local ok, res = xpcall(basalt.autoUpdate, log_traceback)
if not ok then
error(res)
end
utils.log('Execution succeeded')
In the code above, log_traceback
and the code inside the if
will never execute, regardless of the failure status of autoUpdate
.
local filePath = "/basalt.lua"
if not(fs.exists(filePath))then
shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", ""))
end
local basalt = require(filePath:gsub(".lua", ""))
local main = basalt.createFrame()
local thread = main:addThread()
local function yourCustomHandler()
while true do
os.sleep(1)
error("Horrible error") --Error
end
end
thread:start(yourCustomHandler)
local success, err = pcall(basalt.autoUpdate)
if success then
-- Currently, it'll follow this path, as though the execution succeeded.
print('Success')
else
-- I wish it would follow this path, which is the failure path.
print('Error: ', err)
end
Calling error
with the message displayed passed as an argument that can be catched.
Does this have support for advanced monitors?
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
Checklist
[ ] I am running the latest version.
Tick the box if you are running the latest version!
Is your feature request related to a problem? Please describe.
I am frustrated cause its difficult to add support for another image format to Basalt (cimg2 in my case).
Describe the solution you'd like
I would like for there to be some kind of more modular way of handling images, perhaps with a separate library.
Describe alternatives you've considered
Modifying most Basalt code just so it might work.
Describe the bug
When you use os.pullEvent in a thread the filter is ignored.
To Reproduce
local basalt = require("basalt")
local main = basalt.createFrame():setTheme({FrameBG = colors.lightGray, FrameFG = colors.black})
local thread = main:addThread()
thread:start(function()
while true do
print(textutils.serialize({os.pullEvent("key_up")}))
-- Now I'm not sure if this code would work
-- Just because the basalt event handler isn't running when I try to start this thread
-- but my point still stands
-- if it does work, this will error. It will instead catch one of the basalt events, one that has functions in the table returned therefor crashing the program.
end
end)
basalt.autoUpdate()
Expected behavior
The example above wouldn't crash, because it would only ever resume on "key_up" events
Screenshots
N/A
Additional context
N/A
Checklist
[ ] I am running the latest version.
Tick the box if you are running the latest version!
I am running the DEV branch, from when you told me to update it
Describe the bug
basal.autoUpdate() works fine for me, however basalt.update() seems to be messing up events
To Reproduce
Steps to reproduce the behavior:
while true do basalt.update(os.pullEventRaw())
Expected behavior
Given code being equivalent of autoUpdate (without drawFrames)
Additional context
I think it's due to xpcall not passing parameters in computercraft's lua version.
https://github.com/Pyroxenium/Basalt/blob/master/Basalt/main.lua#L409
Swapped my update for:
update = function(event, ...)
local args = {...}
local function f()
basaltUpdateEvent(event, table.unpack(args))
end
local ok, err = xpcall(f, debug.traceback)
if not(ok)then
basaltError(err)
return
end
end,
and it works fine now
Checklist
[ ] I am running the latest version.
Tick the box if you are running the latest version!
Describe the bug
Calling the addObject
function with a directory path doesn't seem to do anything at all - custom object modules are not required.
It looks like all this function does is add the provided path to newObjects
in main.lua
, but newObjects
is only ever visted when main.lua
is first evaluated (i.e. when the module is require
d, before the addObject
function can even be called).
To Reproduce
Steps to reproduce the behavior:
basalt.addObject("...")
in a test programExpected behavior
The custom object modules would be imported and registered as object types in Basalt.
Checklist
Describe the bug
I'm trying to run a code snippet shared in https://basalt.madefor.cc/#/objects/Frame
local basalt = require("basalt") -- we need basalt here
local main = basalt.createFrame():setTheme({FrameBG = colors.lightGray, FrameFG = colors.black}) -- we change the default bg and fg color for frames
local sub = { -- here we create a table where we gonna add some frames
main:addFrame():setPosition(1, 2):setSize("{parent.w}", "{parent.h - 1}"), -- obviously the first one should be shown on program start
main:addFrame():setPosition(1, 2):setSize("{parent.w}", "{parent.h - 1}"):hide(),
main:addFrame():setPosition(1, 2):setSize("{parent.w}", "{parent.h - 1}"):hide(),
}
local function openSubFrame(id) -- we create a function which switches the frame for us
if(sub[id]~=nil)then
for k,v in pairs(sub)do
v:hide()
end
sub[id]:show()
end
end
local menubar = main:addMenubar():setScrollable() -- we create a menubar in our main frame.
:setSize("{parent.w}")
:onChange(function(self, val)
openSubFrame(self:getItemIndex()) -- here we open the sub frame based on the table index
end)
:addItem("Example 1")
:addItem("Example 2")
:addItem("Example 3")
-- Now we can change our sub frames, if you want to access a sub frame just use sub[subid], some examples:
sub[1]:addButton():setPosition(2, 2)
sub[2]:addLabel():setText("Hello World!"):setPosition(2, 2)
sub[3]:addLabel():setText("Now we're on example 3!"):setPosition(2, 2)
sub[3]:addButton():setText("No functionality"):setPosition(2, 4):setSize(18, 3)
basalt.autoUpdate()
But it throws an error dynamicValues.lua:51: attempt to preform arithmetic on a table value
To Reproduce
Steps to reproduce the behavior:
Basalt
as basalt
Expected behavior
Example code should work
Screenshots
Additional context
Checklist
[X] I am running the latest version.
Tick the box if you are running the latest version!
The previous position of the Input
's cursor is maintained when a setValue
call is followed by a setFocus
call, even when the input is empty.
--Basalt configurated installer
local filePath = "/basalt.lua" --here you can change the file path default: basalt
if not(fs.exists(filePath))then
shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command
end
local basalt = require(filePath:gsub(".lua", ""))
local main = basalt.createFrame("mainFrame")
local input = main:addInput('input')
:setPosition(1, 1)
:setSize(20, 1)
:setValue('Some Text')
local button = main:addButton('button')
:setPosition(1, 2)
:setSize(20, 1)
:setValue('Button')
:onClickUp(function()
-- Important part
input:setValue('')
input:setFocus()
end)
basalt.autoUpdate()
Input
input:setValue('')
input:setFocus()
The cursor would return to the rightmost side of the input.
[x] I am running the latest version.
basalt overrides custom palettes
-- Modified version of @1Turtle's GNOME palette
-- black set back to default
-- and using the phoenix installer orange
local GNOME = {
["black"] = 0x111111,
["blue"] = 0x2A7BDE,
["brown"] = 0xA2734C,
["cyan"] = 0x2AA1B3,
["gray"] = 0x5E5C64,
["green"] = 0x26A269,
["lightBlue"] = 0x33C7DE,
["lightGray"] = 0xD0CFCC,
["lime"] = 0x33D17A,
["magenta"] = 0xC061CB,
["orange"] = 0xD06018,
["pink"] = 0xF66151,
["purple"] = 0xA347BA,
["red"] = 0xC01C28,
["white"] = 0xFFFFFF,
["yellow"] = 0xF3F03E
}
for color, code in pairs(GNOME) do
term.setPaletteColor(colors[color], code)
end
CraftOSPC
No response
Describe the bug
When using gps.locate() inside a thread, it wont return the gps coordinates
Expected behavior
Returning the gps values inside a thread.
[ x] I am running the latest version.
It seems we're limited to using the standard colors provided by the colors
library. Using colors created with colors.packRGB
results in an error, as the color lookup in the tHex
library fails. I'd Like to be able to use custom colors for gradients in heat graphs and darkening buttons when clicked.
Are there plans to support custom colors, and is this even supported by the monitors?
If the text (or value
) in the button is longer than its width, the text will overflow the button's bounding box.
-- Basalt configurated installer
local filePath = "/basalt.lua" --here you can change the file path default: basalt
if not(fs.exists(filePath))then
shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command
end
local basalt = require(filePath:gsub(".lua", ""))
local main = basalt.createFrame("mainFrame")
main:addButton('button')
:setPosition(20, 8)
:setSize(10, 3)
:setValue('some very very long name')
basalt.autoUpdate()
The text would be "cut off" the bounding box of the button.
[✔️] I am running the latest version
Image doesn't appers on screen.
Steps to reproduce the behavior:
require()
and autoUpdate()
functionExpected: Image appers on screen
[ V] I am running the latest version.
Tick the box if you are running the latest version!
Attempt to debug a thread by displaying a value using basalt.debug
crashes the program.
CraftOSPC
I wish this was copypastable
basalt.lua:2209: Thread Error Occured - cannot resume running coroutine
2209 in eventHandler
713 in eventHandler
71 in cab (one of the minified functions)
this was in an xpcall
80 in autoUpdate
Note: I'm not sure if this is a bug or expected behaviour.
Describe the bug
Say you have inputs A and B. If you use B:setFocus()
inside of A:onKey
, pressing a key inside of A will output it to B.
To Reproduce
local A = main_frame:addInput("A")
:setPosition(1, 1)
:setSize(20, 1)
:show()
local B = main_frame:addInput("B")
:setPosition(1, 2)
:setSize(20, 1)
:show()
A:onKey(function(self, event, key)
B:setFocus()
end)
The output 'a' will be produced to B.
Expected behavior
Again... I'm now sure if this is a bug, or expected behaviour. However, I expected the 'a' to appear in the first input, and then the focus be set to B.
Screenshots
Checklist
[x] I am running the latest version.
Tick the box if you are running the latest version!
Type: Feature request
Hey,
I think it would be cool if we could implement something like Bigfont by Wojbie or something similar for labels.
I have an example of BigFont beeing used, see image below:
Here you can see the "PixelTech INC" sized big, using BigFont, and under the "maybe?", using normal text.
I can imagine the api to be something like this:
label:setFontSize(font size)
, where font size is 1 for normal, 2 for bigger, 3 for even bigger, etc, etc.
As the title says, the docs contain a Basalt.setTheme()
function which appears to no longer exist.
When I load Basalt and run the Basalt.setTheme()
from the Lua prompt (or any other file) I get the following error (even if I pass a correct table):
** Possible solutions **
setTheme()
function.** Others **
I have downloaded the recent Minified/Packed Version
a few minutes ago.
** Checklist **
[ X ] I am looking at the latest version of the docs.
Is your feature request related to a problem? Please describe.
The hard cap to 100 entries in Graph is limiting the ability for Telem's integration to show more data: cyberbit/telem#49
Describe the solution you'd like
An API that allows overriding the hard limit on maximum entries, with the caveat that it is a potential memory leak issue, and to proceed with caution.
Describe alternatives you've considered
I have considered limiting my implementation to 100 maximum entries to match Basalt, but want to leave that as a last resort.
Additional context
The chart here is scaled to fill the entire screen, but because of the 100 entry limit, appears misconfigured:
Using :wait
before one of the build-in animations (:size
, :position
, offset
, etc) will not wait before executing the animation.
-- Basalt configurated installer
local filePath = "/basalt.lua" --here you can change the file path default: basalt
if not(fs.exists(filePath))then
shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command
end
local basalt = require(filePath:gsub(".lua", ""))
local main = basalt.createFrame("mainFrame")
local W, H = main:getSize()
-- Frame using built-in animation (size) will not properly wait.
local frame_not_working = main:addFrame("frame_not_working")
frame_not_working:setSize(math.floor(W/2)-2, H-2)
frame_not_working:setPosition(2, 2)
frame_not_working:setBackground(colors.black)
frame_not_working:setBorder(colors.white)
local animation_not_working = main:addAnimation("animation_not_working")
:setObject(frame_not_working)
:setMode("linear")
-- This will fail. It will not wait 3 seconds.
:wait(3)
:size(math.floor(W/2)-2, 0, 0.5)
:onDone(function()
frame_not_working:remove()
end)
-- Frame avoiding built-in animation (manually resizing) will wait.
local frame_working = main:addFrame("frame_working")
frame_working:setSize(math.floor(W/2)-2, H-2)
frame_working:setPosition(math.floor(W/2)+1, 2)
frame_working:setBackground(colors.black)
frame_working:setBorder(colors.white)
local animation_working = main:addAnimation("animation_working")
:setObject(frame_working)
-- This will succeed, it will wait 3 seconds.
:wait(3)
for _ = 1, H-3 do
animation_working:add(function()
frame_working:setSize(0, -1, 'r')
end)
:wait(0.01)
end
animation_working:onDone(function()
frame_working:remove()
end)
-- Execute.
animation_not_working:play()
animation_working:play()
basalt.autoUpdate()
Wait the amount specified in :wait
before starting built-in animation.
[✔️] I am running the latest version.
Describe the bug
The textfield object crashes the basalt when new line is added and removed.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
It should remove line, instead of crashing.
Screenshots
Additional context
No matter the surrounding, the textfield fails under the above conditions.
Checklist
Tick the box if you are running the latest version!
Describe the bug
Side-specific border coloring when making the UI with .xml does not work properly.
To Reproduce
Steps to reproduce the behavior:
<button x="2" y="2" text="Hello" borderBottom="blue" />
Basalt error: .../basaltDraw.lua:202: bad argument (string expected, got nil)
Expected behavior
A button with the text "Hello" should appear with a blue border only along the bottom
Additional context
Changing these four lines (138-141) in Object.lua
seems to fix it! Just had to wrap the xmlValue(...)
return with colors[...]
, like the other surrounding code does.
if(xmlValue("borderLeft", data)~=nil)then borderColors["left"] = colors[xmlValue("borderLeft", data)] end
if(xmlValue("borderTop", data)~=nil)then borderColors["top"] = colors[xmlValue("borderTop", data)] end
if(xmlValue("borderRight", data)~=nil)then borderColors["right"] = colors[xmlValue("borderRight", data)] end
if(xmlValue("borderBottom", data)~=nil)then borderColors["bottom"] = colors[xmlValue("borderBottom", data)] end
Checklist
[x] I am running the latest version.
Tick the box if you are running the latest version!
The function documented here, "setTextAlign" is nil.
How to replicate:
local basalt = dofile("lib/basalt")
local mainFrame = basalt.createFrame("mainFrame"):show()
local label = mainFrame:addLabel("label"):setSize(45,1):setValue("This is a label"):setTextAlign("center","center"):show()
basalt.autoUpdate()
This errors: test.lua:3: attempt to call method 'setTextAlign' (a nil value)
It seems it's on Button, not Object?
I would like support for Nitrogen Fingers Text, witch has support built in to CC:Tweaked, but no support in basalt
Additional context
public editor (npaintpro by nitrogenfingers)
2 examples of Nitrogen Fingers Text images example.zip
cc.image.nft documentation on https://tweaked.cc
Is your feature request related to a problem? Please describe.
It Is Extremely Annoying when I Have To Go To The Frame Section In The Docs To Find Examples And New Users Would Not Know Where To Find Them
Describe the solution you'd like
I Think The Examples Should Be Moved From The Frame Section To Somewhere Else
Describe alternatives you've considered
I have Considered Adding Something To Tell The User Where The Examples Are But I Think It Would Still Be Too Hard To Find
Note: I'm not sure if this is a bug report or a feature request (i.e. if this is unintended or intended behaviour).
An expanded Dropdown
may have items inaccessible, as Frame
scrolling is disabled while the dropdown is expanded.
local filePath = "/basalt.lua"
if not(fs.exists(filePath))then
shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", ""))
end
local basalt = require(filePath:gsub(".lua", ""))
local main = basalt.createFrame("mainFrame"):setScrollable()
local w, h = term.getSize()
for i=1,5 do
main:addDropdown('dropdown_'..tostring(i))
:setPosition(2, h+i-2)
:setSize(10, 1)
:addItem('Item 1')
:addItem('Item 2')
:addItem('Item 3')
:show()
end
basalt.autoUpdate()
In the example above, Item 2
and Item 3
are inaccessible, as:
Frame
Dropdown
is expandedBe able to scroll further down the Frame
while the Dropdown
is expanded.
[x] I am running the latest version.
Describe the bug
When a button gets clicked, instead of a string like "mouse_click"
or "mouse_up"
the event
(2nd parameter) is a table.
To Reproduce
Steps to reproduce the behavior:
local basalt = require("basalt")
local main = basalt.createFrame()
main:addButton()
:setText("Start")
:setPosition(1, 1)
:setSize("7", "1")
:onClick(function(self, event, button, x, y)
basalt.debug("Event ("..tostring(event)..") = {")
if type(event) == "table" then
for k, v in pairs(event) do
basalt.debug(k.."="..tostring(v)..",")
end
end
basalt.debug("}")
end)
basalt.autoUpdate()
Expected behavior
Once the button is clicked, the Basalt debug window will contain:
Event (mouse_click) = {
}
Screenshots
If applicable, add screenshots to help explain your problem.
^ The contents of the event
.
Additional context
Add any other context about the problem here.
N/A ?
Checklist
[ X ] I am running the latest version.
Tick the box if you are running the latest version!
In each class that inherits from other classes.
I really like the way the roblox documentation does this, it lists the methods the object itself has (like currently done), but beneath that it has dropdowns for "Inherited from <X>"
The current way does work, but having something like this will reduce the need to click back and forth through multiple pages.
I also notice that sometimes the In addition to the A and B methods, X objects have the following methods:
statement is sometimes missing base class methods (currently I am looking at Input
, which is missing ChangeableObject
).
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Parsing XML (or HTML) can be a challenge in Lua. Having the ability to register custom XML parsers will allow people to do this.
Describe the solution you'd like
A clear and concise description of what you want to happen.
The creation of a system that allows people to make custom XML parsers which support custom tags. Each custom tag should be predefined.
Example lua:
-- This function will allow people to do what they want if a tag is parsed for example add it to a layout.
-- This function will be called for all tags. Parent tags (tags with child tags) will have this function run first on them, this could allow custom data to be passed to child tags.
local function parse(tag)
local name = tag.name -- the name of the tag
local attrs = tag.attrs -- the tag's attributes
local children = tag.children -- the tag's children (a table of other tags in the same format) (or a string if it is just text e.g. `<p>text here</p>`)
if name == "p" then
if not tag.inDiv then
frame:addLabel():setText(children) -- amusing `frame` is a `Frame` and `children` is a `string`
end
end
if name == "div" then
for k,v in pairs(children) do
v.inDiv = true -- set a custom value on the children of this div
end
end
end
local tags = {
p = { -- define a tag called "p"
children = "string" -- this will allow only strings inside a `p` if other types are found (like and other tag) then there will be an error. Single numbers should be parsed as a string.
},
div = { -- define a tag called "div"
children = "any" -- allow anything inside a div
}
}
local parser = basalt.makeParser(tags, parse)
-- The parser object shall work like the normal XML parser with the same `:loadLayout`. In addition there should be a `:loadString` which takes the XML code as a string instead of a file name.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Copying your existing XML parser and modifying it.
Additional context
Add any other context or screenshots about the feature request here.
This will allow me to make a better HTML parser for my CC Browser and have a very nice UI.
Describe the bug
When trying to use the function removeChild with an ID of an element this gives an error
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The specified children of the container gets removed.
Probable cause
The problems seems to be that when passing a string it tries to call the method getName() which is a method of basalt Object's (2nd screenshot)
Screenshots
Checklist
[x] I am running the latest version.
Currently, if you have multiple dropdowns in a frame, they are prioritized in the order they were added (last in the top).
This means that if you are adding a bunch of dropdowns in a column (perhaps using a for
loop), the dropdown box of the ones above will be overshadowed by the label of the ones below.
-- Basalt configurated installer
local filePath = "/basalt.lua" --here you can change the file path default: basalt
if not(fs.exists(filePath))then
shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command
end
local basalt = require(filePath:gsub(".lua", ""))
local main = basalt.createFrame("mainFrame")
for i = 1, 3 do
local fg_color, bg_color
if i % 2 == 0 then
fg_color = colors.black
bg_color = colors.white
else
fg_color = colors.white
bg_color = colors.black
end
main:addDropdown('dropdown_'..i)
:setPosition(20, 6 + (2*i))
:setSize(10, 1)
:addItem('Option 1')
:addItem('Option 2')
:addItem('Option 3')
:addItem('Option 4')
:addItem('Option 5')
:setForeground(fg_color)
:setBackground(bg_color)
:selectItem(1)
end
basalt.autoUpdate()
For me, a reasonable solution would be to prioritize rendering the dropdown box over the dropdown label whenever they are in the same index.
for
loop. (i.e. for i = 3, 1, -1 do
):setZIndex(3 - i)
)Although the workarounds (from my part) are quite simple, I think it's reasonable for a developer using the API to assume the dropdowns boxes (on the same level) would be prioritized over labels.
As an example, in the Windows API for GUI, it's true (and expected) that if you add a couple of dropdowns in a column one after another, when you click on the first dropdown, its box won't be overshadowed by the dropdowns below it. I think it's reasonable to assume the same behaviour in basalt.
Edit: I now realize this is probably a bug report, not a feature request... oh well ¯\_(ツ)_/¯
Making a frame with borders 1-wide creates seemingly undefined behaviour (in terms of how the borders will be drawn). In general, only one side is drawn at a time, leading to the other side being "open".
-- Basalt configurated installer
local filePath = "/basalt.lua" --here you can change the file path default: basalt
if not(fs.exists(filePath))then
shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command
end
local basalt = require(filePath:gsub(".lua", ""))
local main = basalt.createFrame("mainFrame")
local W, H = main:getSize()
local frame = main:addFrame("frame")
frame:setSize(W-2, math.floor(H/2))
frame:setPosition(2, 5)
frame:setBackground(colors.black)
frame:setBorder(colors.white)
local animation = main:addAnimation("animation")
:setObject(frame)
:size(1, math.floor(H/2), 0.5, 0.5)
animation:play()
basalt.autoUpdate()
When becoming one-wide, a frame with border of color X should be completely filled by color X (simulating drawing on both sides of the border).
-- Basalt configurated installer
local filePath = "/basalt.lua" --here you can change the file path default: basalt
if not(fs.exists(filePath))then
shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command
end
local basalt = require(filePath:gsub(".lua", ""))
local main = basalt.createFrame("mainFrame")
local W, H = main:getSize()
local frame = main:addFrame("frame")
frame:setSize(W-2, math.floor(H/2))
frame:setPosition(2, 5)
frame:setBackground(colors.black)
frame:setBorder(colors.white)
local animation = main:addAnimation("animation")
:setObject(frame)
:size(2, math.floor(H/2), 0.5, 0.5)
:onDone(function()
frame:setSize(1, math.floor(H/2))
frame:setBackground(colors.white)
end)
animation:play()
basalt.autoUpdate()
local filePath = "/basalt.lua"
if not(fs.exists(filePath))then
shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", ""))
end
local basalt = require(filePath:gsub(".lua", ""))
local main = basalt.createFrame("mainFrame")
-- This is fine.
local textfield_0 = main:addTextfield('textfield_0')
:setPosition(1, 1)
:setSize(20, 3)
-- two addLine
:addLine('Value')
:addLine('Another Value')
-- no removeLine
-- This is fine.
local textfield_1 = main:addTextfield('textfield_1')
:setPosition(1, 5)
:setSize(20, 3)
-- two addLine
:addLine('Value')
:addLine('Another Value')
-- one removeLine
:removeLine()
-- This gets deformed.
local textfield_2 = main:addTextfield('textfield_2')
:setPosition(1, 9)
:setSize(20, 3)
-- two addLine
:addLine('Value')
:addLine('Another Value')
-- two removeLine
:removeLine()
:removeLine()
basalt.autoUpdate()
As seen in the MWE above, textfield_2
gets deformed by the second call to removeLine()
.
The Textfield
maintains its shape.
[X] I am running the latest version.
--Basalt configurated installer
local filePath = "/basalt.lua" --here you can change the file path default: basalt
if not(fs.exists(filePath))then
shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command
end
local basalt = require(filePath:gsub(".lua", ""))
local main = basalt.createFrame("mainFrame")
local button = main:addTextfield('button')
:setSize(20, 5)
:addLine('something')
basalt.autoUpdate()
If the first line is empty, addLine
would add the text to the first line.
[X] I am running the latest version.
Tick the box if you are running the latest version!
When labels are used with XML, they terminate unexpectedly. This occurs whether or not a space is present in the string, leading me to believe that the XML has a default size parameter that it sets, instead of calculating the size from the label text.
I tested this on CraftOS PC, as well as in 1.19.2 CC:Tweaked.
MRE:
local basalt = require("basalt")
basalt.createFrame():loadLayout("test.xml")
basalt.autoUpdate()
test.xml
<label text="HelloWorld" y="1" />
<label text="Hello World" y="2" />
<label text="HelloWorld" y="3" width="10" />
<label text="Hello World" y="4" width = "11" />
Ingame (Default)
No response
local filePath = "/basalt.lua" --here you can change the file path default: basalt
if not(fs.exists(filePath))then
shell.run("pastebin run ESs1mg7P packed true "..filePath:gsub(".lua", "")) -- this is an alternative to the wget command
end
local basalt = require(filePath:gsub(".lua", ""))
local main = basalt.createFrame("mainFrame")
local function visual_button(btn)
btn:onClick(function(self) btn:setBackground(colors.black) btn:setForeground(colors.lightGray) end)
btn:onClickUp(function(self) btn:setBackground(colors.gray) btn:setForeground(colors.black) end)
btn:onLoseFocus(function(self) btn:setBackground(colors.gray) btn:setForeground(colors.black) end)
end
local working_frame = main:addFrame("working_frame")
:setPosition(2, 2)
:setSize(20, 10)
:setBackground(colors.black)
-- This will work fine (notice that it's done before adding the children).
:setZIndex(1000)
local working_input = working_frame:addInput("input")
:setPosition(2, 2)
:setSize(18, 1)
:setDefaultText("Search Text")
local working_button = working_frame:addButton("button")
:setPosition(2, 4)
:setSize(18, 1)
:setValue("Search")
visual_button(working_button)
local not_working_frame = main:addFrame("not_working_frame")
:setPosition(23, 2)
:setSize(20, 10)
:setBackground(colors.black)
local not_working_input = not_working_frame:addInput("input")
:setPosition(2, 2)
:setSize(18, 1)
:setDefaultText("Search Text")
local not_working_button = not_working_frame:addButton("button")
:setPosition(2, 4)
:setSize(18, 1)
:setValue("Search")
visual_button(not_working_button)
-- This will effectively disable the children (notice that it's done after adding the children).
not_working_frame:setZIndex(1000)
main:show()
basalt.autoUpdate()
Children being interactable after changing the ZIndex of parent.
[X] I am running the latest version.
Describe the bug
When I call basalt.setActiveFrame
, nothing happens. The current frame is still the previous frame.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
It should set the active frame, make it so it is displayed, and receive events.
Checklist
[x] I am running the latest version.
Assuming the latest version is the latest release on github (1.7), yes I am.
I've installed basalt and set up my first program following the tutorial.
I've set up a button by using
local btnGate = controlfram
:addButton()
:setPosition(2,2)
:setText("[ OPEN ]")
:setBackground(colors.yellow)
I originally had the onclick set up as part of the call chain, but have movied it to be it's own section
btnGate:onClick(function(self,event,button,x,y)
basalt.debug("CLICK EVENT")
if (event == "mouse_click") and (button == 1) then
basalt.debug("CLICKED")
open("gate") --My function call for my gates
end
end)
after this I have the basalt.autoUpdate() call.
The program starts up, and I can drag the movableframe around like it's supposed to, but clicking a button never does anything. And the debug events are never called. I'm not sure why.
Checklist
[ X] I am running the latest version.
Describe the bug
When using buttons in XML, if the text is set to only numbers, Basalt crashes. This bug only happens when you create buttons via XML.
If the text field has any non-numeric character the bug doesn't happen.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
It should just show the numbers, as it does when you programmatically create a button.
Checklist
[x] I am running the latest version.
Tick the box if you are running the latest version!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.