add RadioButton Lua class
This commit is contained in:
@@ -84,6 +84,29 @@ function Document.new(docname)
|
||||
})
|
||||
end
|
||||
|
||||
local _RadioGroup = {}
|
||||
function _RadioGroup.set(self, key)
|
||||
if self.current then
|
||||
self.elements[self.current].enabled = true
|
||||
end
|
||||
self.elements[key].enabled = false
|
||||
self.current = key
|
||||
if self.callback then
|
||||
self.callback(key)
|
||||
end
|
||||
end
|
||||
function _RadioGroup.__call(self, elements, onset, default)
|
||||
local group = setmetatable({
|
||||
elements=elements,
|
||||
callback=onset,
|
||||
current=nil
|
||||
}, {__index=_RadioGroup})
|
||||
group:set(default)
|
||||
return group
|
||||
end
|
||||
setmetatable(_RadioGroup, _RadioGroup)
|
||||
RadioGroup = _RadioGroup
|
||||
|
||||
_GUI_ROOT = Document.new("core:root")
|
||||
_MENU = _GUI_ROOT.menu
|
||||
menu = _MENU
|
||||
|
||||
Reference in New Issue
Block a user