Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- load ALL the APIs!
- os.loadAPI("RBB/helper")
- os.loadAPI("RBB/guiElements")
- os.loadAPI("RBB/screen")
- -- Function for the Buttons, just prints the parameter
- function fancyFunction(p1, p2)
- print(tostring(p1) .. " , " .. tostring(p2))
- end
- -- Function for Picker, just prints the parameter
- function incdecFunction(param)
- print("incdec: " .. tostring(param))
- end
- -- Create a new Screen. The Monitor is on the "right" and will have a 4 by 4 grid
- local rows = 4
- local cols = 4
- local thisScreen = screen.Screen.create("right", rows, cols)
- -- Lets make some buttons
- -- For more detailed info, look into the documentation ;)
- local btn = guiElements.Button.create("1", "Button", false, fancyFunction, {"Button", "derp"})
- local btn2 = guiElements.Button.create("2", "Button2", true, fancyFunction, {"Button2", "derp"})
- local btn3 = guiElements.Button.create("3", "Button3", false, fancyFunction, {"Button3", "derp"})
- local btn4 = guiElements.Button.create("4", "Button4", false, fancyFunction, {"Button4", "derp"})
- -- Lets make some RadioButtons:
- -- The radioIndex can be a string or a number, it's just there to group the buttons
- btn3:setRadioIndex("herpderp")
- btn4:setRadioIndex("herpderp")
- -- And now a label
- local lbl = guiElements.Label.create("123","Down here!",{h = "center", v = "center"})
- -- and when where at it, lets turn the background of the label blue!
- lbl:setBGColor(colors.blue)
- lbl:setTextPosition({h = "right", v = "bottom"})
- -- Now we create a "Picker". This one's a bit complicated
- -- First two parameters are like button and label, but the 3rd is the starting index for the table in the 4th parameter
- -- The index is 2 so we start with "def"
- local picker = guiElements.Picker.create("picky", "Picker1", 2, {"abc", "def", "ghi", "jkl"})
- -- Set the function that is called when the "-" is clicked
- picker:setDecFunction(incdecFunction)
- -- Set the function that is called when the "+" is clicked
- picker:setIncFunction(incdecFunction)
- -- Add ALL the elements to the grid
- thisScreen:addElementToGrid(picker,2,3)
- -- This ones is different! the buttons will have a 2x2 size
- thisScreen:addElementToGrid(btn,{1,2},{1,2})
- thisScreen:addElementToGrid(btn2,1,3)
- thisScreen:addElementToGrid(btn3,3,2)
- thisScreen:addElementToGrid(btn4,4,1)
- thisScreen:addElementToGrid(lbl,4,{2,3,4})
- -- This has to be called after adding all the elements, it just sets up each element...the automatic stuff ;)
- thisScreen:initGrid()
- -- Initially draws everything, only needs to be called once
- thisScreen:draw()
- -- Basic loop to get the touch events from the monitor and check them on the screen
- while true do
- event,side,x,y = os.pullEvent("monitor_touch")
- thisScreen:checkTouchEvent(event,side,x,y)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement