Skip to content

Instantly share code, notes, and snippets.

@rudyryk
Created November 9, 2021 12:56
Show Gist options
  • Save rudyryk/7d5e3cfa37b1bb24b2529cb3e4865817 to your computer and use it in GitHub Desktop.
Save rudyryk/7d5e3cfa37b1bb24b2529cb3e4865817 to your computer and use it in GitHub Desktop.
SpheroidScript interactive example with button and label
{
"client": [
"./InteractiveClient.spheroid"
],
"version": "1.0.0"
}
var counter = 0
var counterText = null
fun main() {
println("Hello from InteractiveClient")
MainMenu {
Container(top = 60dp, right = 20dp, bottom=60dp, left = 20dp) {
Vertical(spacing = 0, left = 0, right = 0, verticalAlign = "center") {
Container(
backgroundColor = Color(rgba = 0x00000033),
height = 50dp
) {
counterText = Text(
text = "---",
textColor = Color(rgba = 0xffffffaa),
left = 20dp,
verticalAlign = "center"
)
}
Container(
backgroundColor = Color(rgb = 0x0000aa),
height = 50dp
) {
Text(
text = "Button",
textColor = Color(rgba = 0xffffffaa),
left = 20dp,
verticalAlign = "center"
)
}.onClick { doClick() }
}
}
}
}
fun doClick() {
counter = counter + 1
println("Clicked: ${counter}")
counterText.text = "${counter}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment