This commit is contained in:
NoryiE
2025-10-30 08:24:17 +00:00
parent 42624f0a8a
commit e05e05423a
5 changed files with 246 additions and 9 deletions

View File

@@ -3,6 +3,62 @@ _This is the program class. It provides a program that runs in a window._
Extends: `VisualElement`
## Examples (Executable)
```lua run
local basalt = require("basalt")
local main = basalt.getMainFrame()
local execPath = "rom/programs/fun/worm.lua"
local btn = main:addButton({
x = 5,
y = 2,
width = 20,
height = 3,
text = "Run Worm",
}):onClick(function()
local frame = main:addFrame({
x = 2,
y = 2,
width = 28,
height = 10,
title = "Worm Program",
draggable = true,
})
:setDraggingMap({{x=1, y=1, width=27, height=1}})
:onFocus(function(self)
self:prioritize()
end)
local program = frame:addProgram({
x = 1,
y = 2,
width = 28,
height = 9,
})
program:execute(execPath)
frame:addLabel({
x = 2,
y = 1,
text = "Worm",
foreground = colors.lightBlue
})
frame:addButton({
x = frame.get("width"),
y = 1,
width = 1,
height = 1,
text = "X",
background = colors.red,
foreground = colors.white
}):onClick(function()
frame:destroy()
end)
end)
basalt.run()
```
## Properties
|Property|Type|Default|Description|