Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local gui = require "gui"
- local buffer = createBuffer(term, "buffer", colors.pink)
- local button1 = Text:new {
- name = "button1",
- buffer = buffer,
- parent = buffer,
- x = 2,
- text = "lorem ipsum",
- horizontalAlignment = align.center,
- verticalAlignment = align.center,
- backgroundColor = colors.red,
- width = 11,
- height = 1,
- padding = 0,
- }
- registerSelectionCallback("mouse_click", button1, function(element, event, button, x, y)
- if button == 1 then
- button1:setBackgroundColor(2^math.random(15))
- end
- end, "buttonClick")
- local button2 = Text:new {
- name = "button2",
- buffer = buffer,
- parent = buffer,
- x = 2,
- y = 3,
- text = "kaibochan",
- horizontalAlignment = align.center,
- verticalAlignment = align.center,
- backgroundColor = colors.blue,
- width = 11,
- height = 1,
- padding = 0,
- }
- registerSelectionCallback("mouse_click", button2, function(element, event, button, x, y)
- if button == 1 then
- button2:setBackgroundColor(2^math.random(15))
- elseif button == 2 then
- button2:setTextColor(2^math.random(15))
- end
- end, "buttonClick")
- local textBox = Textbox:new {
- name = "textBox1",
- buffer = buffer,
- parent = buffer,
- x = 25,
- y = 2,
- width = 20,
- height = 5,
- backgroundColor = colors.red,
- textColor = colors.orange,
- }
- local text = Text:new {
- name = "text",
- x = 2,
- y = 2,
- width = 5,
- height = 2,
- text = "Lorem ipsum dolor sit amet."
- }
- local textBox2 = Textbox:new {
- name = "textBox2",
- x = 8,
- y = 3,
- width = 10,
- height = 3,
- padding = 0,
- }
- local window = Window:new {
- name = "window",
- buffer = buffer,
- parent = buffer,
- x = 1,
- y = 5,
- width = 20,
- height = 10,
- contents = { text, textBox2 },
- }
- while true do
- buffer:draw()
- parallel.waitForAny(handleInputEvents())
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement