Advertisement
1lann

UI Framework Test

Nov 21st, 2015
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1. shell.run("ui.lua")
  2.  
  3. local renderer = Renderer.new()
  4. renderer:setScrollable(true)
  5. renderer:setScrollHeight(renderer.height + 15)
  6.  
  7. local button = Button.new()
  8. renderer:add(button)
  9.  
  10. local overlayText = Content.new(term.getSize())
  11. renderer:add(overlayText)
  12.  
  13. local function writeInButton(text)
  14.     local content = button:getContent()
  15.     content:clear()
  16.     content:newLine()
  17.     content:setTextColor(colors.white)
  18.     content:addLine(text, "center")
  19. end
  20.  
  21. button:setPosition({1, 7})
  22. button:setColor(colors.blue)
  23. button:setSize(20, 4)
  24. button:setLayer(5)
  25. button:setAttr("clicked", false)
  26. writeInButton("Hello, world!")
  27.  
  28. button:setOnClick(function()
  29.     if not button:getAttr("clicked") then
  30.         writeInButton("Clicked :)")
  31.         button:setAttr("clicked", true)
  32.  
  33.         setTimeout(function()
  34.             writeInButton("Not clicked :(")
  35.             button:setAttr("clicked", false)
  36.             renderer:forceRender()
  37.         end, 1)
  38.     end
  39. end)
  40.  
  41. overlayText:setTextColor(colors.white)
  42. overlayText:setPosition({0, 12})
  43. overlayText:write("This is a long string as a test!")
  44. overlayText:setPosition({0, 30})
  45. overlayText:write("And this string cannot be seen without scrolling!")
  46. overlayText:setLayer(2)
  47.  
  48. renderer:execute()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement