Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if viewportAPI then os.unloadAPI("viewportAPI") end
- os.loadAPI("viewportAPI")
- if buttonAPI then os.unloadAPI("buttonAPI") end
- os.loadAPI("buttonAPI")
- if eventDispatcherAPI then os.unloadAPI("eventDispatcherAPI") end
- os.loadAPI("eventDispatcherAPI")
- viewport = viewportAPI.new({term = peripheral.wrap("back")})
- button = buttonAPI.new({
- text = "test",
- x = 5,
- y = 5,
- height = 1,
- width = 6,
- isSticky = false,
- backgroundColor = colors.green
- })
- viewport:addElement(button)
- viewport:redraw()
- function clickHandler(element, posX, posY)
- element.backgroundColor = element.backgroundColor == colors.red and colors.green or colors.red
- return true
- end
- button.callback = clickHandler
- while true do
- event, side, xPos, yPos = os.pullEvent("monitor_touch")
- viewport:handleClick(xPos, yPos)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement