Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local EVENT -- List of all os.pullEvent() variables
- local GUI_DATA -- List of all components data: ["Component_1"] = [{x, y}, {x, y}, func()]
- function init(GUI) -- New eventhandler for new GUI
- GUI_DATA = GUI.getComponents()
- end
- function timed_mouseclick_Event(t)
- os.startTimer(t)
- EVENT = {os.pullEvent()}
- if EVENT[1] == "timer" then
- return
- else
- mouse_clickListener(EVENT)
- end;
- end;
- function mouse_clickListener(mouseEvent) -- "Listens" to an eventobject fired by a mouse_click and executes the function given by componentdata
- _,x,y = unpack(mouseEvent)
- for j, k in pairs(GUI_DATA) do
- if x >= k[1].x and x <= k[2].x then
- if y >= k[1].y and y <= k[2].y then
- k.action()
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement