-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Manuel Wegmann edited this page Mar 15, 2021
·
3 revisions
Editable TextLabel allows you to create a Label on which the text can be changed by simply mouse click on it. The change can be hooked to a function.
Simple example:
local function echoLabelText(text)
echo(text)
echo("\n")
end
testCont = testCont or Adjustable.Container:new({name = "testCont", width = "30c", height = "20c"})
testLabel =
testLabel or
Editable.TextLabel:new(
{name = "testLabel",
x = 0, y = 0, width = "100%", height = "100%",
hook = echoLabelText,
format="cb",
message ="my Test Label",
fgColor = "red",
borderStyle = [[border:none;]]},
testCont
)Geyser.Label constraints can be used and additional possible constraints (mostly for styling purposes) are:
borderStyle = command line border style (as string) for example [[border: 2px solid red;]]
cmdBgColor = the command line background colour (as string) for example [[rgba(255,0,0,100)]] (is transparent if not set)
hook = hooked function (see example above)
flexible = boolean if true the label will adjust its size to the text set (false if not set)
ScrollBox allows you to create a Geyser.VBox with which it is possible to scroll through elements.
Simple Example (adding 100 random color Labels)
scrollCont = scrollCont or Adjustable.Container:new({name = "scrollCont"})
testScrollB =
testScrollB or
Adjustable.ScrollBox:new(
{name = "testScrollB", x = 0, y = 0, width = "100%", height = "100%"}, scrollCont
)
-- fill scrollBox with 100 Labels of different colours
scrollLabels = scrollLabels or {}
for i = 1, 100 do
local randomColor =
string.format("<%s,%s,%s>", math.random(255), math.random(255), math.random(255))
scrollLabels[i] =
scrollLabels[i] or
Geyser.Label:new(
{
name = f("scrollLabel{i}"),
color = randomColor,
height = "2c",
format = "cb",
fgColor = "white",
message = i,
},
testScrollB
)
endMore complex example with editable labels and self changing gauges (scroll down to the gauges)
scrollCont2 = scrollCont or Adjustable.Container:new({name = "scrollCont2"})
testScrollB2 =
testScrollB2 or
Adjustable.ScrollBox:new(
{name = "testScrollB2", x = 0, y = 0, width = "100%", height = "100%"}, scrollCont2
)
-- fill scrollBox with editable Labels of different colours
-- EditableTextLabel has to be installed for this to function
scrollLabels2 = scrollLabels2 or {}
scrollGauges = scrollGauges or {}
for i = 1, 100 do
local randomColor =
string.format("<%s,%s,%s>", math.random(255), math.random(255), math.random(255))
if i < 50 then
scrollLabels2[i] =
scrollLabels2[i] or
Editable.TextLabel:new(
{name = f("scrollLabel2{i}"),
color = randomColor,
height = "2c",
format ="cb",
fgColor = "white",
message = i}, testScrollB2
)
else
scrollGauges[i] =
scrollGauges[i] or
Geyser.Gauge:new({name = f"scrollGauge{i}", height = "2c", value = math.random(100)}, testScrollB2)
scrollGauges[i].timer = scrollGauges[i].timer or tempTimer(1.5, function()
local oldvalue = scrollGauges[i].value or 0
local value = 10 < math.random(20) and oldvalue + math.random(5) or oldvalue - math.random(5)
value = value >= 100 and 99 or value <= 0 and 0 or value
scrollGauges[i]:setValue(value,100,f"<center><b>{value}/100")
end, true)
scrollGauges[i]:setColor(math.random(255), math.random(255), math.random(255))
end
end