Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Component Menu for forms.lua, (c)SergOmarov,2015
- local TMenu=setmetatable({W=20, H=10, selColor=0x0000ff, sfColor=0xffff00,
- type=function() return "Menu" end},TComponent)
- TMenu.__index=TMenu
- function TMenu:clear()
- self:redraw()
- end
- function TMenu:paint()
- gpu.setForeground(self.sfColor)
- gpu.setBackground(self.selColor)
- local y=self.top-1
- local x=self.left
- for i=1,#self.items do
- gpu.set(x,y+i,self.items[i].text)
- end
- end
- function TMenu:insert(pos,line,item)
- end
- function TMenu:sort(comp)
- end
- function TMenu:touch(x, y, btn, user)
- self:hide()
- local select=self.items[y] or {text=""}
- if(x<=#select.text)then
- self.items[y].func()
- end
- end
- function TComponent:addMenu(left, top,items)
- local obj={left=left, top=top, items=items}
- self:makeChild(obj)
- local menu=setmetatable(obj,TMenu)
- menu:hide()
- return menu
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement