mirror of
https://github.com/Insality/druid.git
synced 2025-09-28 02:22:18 +02:00
Add druid with context, get component druid as helper.get_druid(context)
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
--- Checkboux group module
|
||||
-- @module base.checkbox_group
|
||||
|
||||
local helper = require("druid.helper")
|
||||
|
||||
local M = {}
|
||||
|
||||
|
||||
local function on_checkbox_click(self, index)
|
||||
if self.callback then
|
||||
self.callback(self.parent.parent, index)
|
||||
self.callback(self.context, index)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,12 +34,13 @@ end
|
||||
|
||||
|
||||
function M.init(self, nodes, callback, click_nodes)
|
||||
self.druid = helper.get_druid(self)
|
||||
self.checkboxes = {}
|
||||
self.callback = callback
|
||||
|
||||
for i = 1, #nodes do
|
||||
local click_node = click_nodes and click_nodes[i] or nil
|
||||
local checkbox = self.parent:new_checkbox(nodes[i], function()
|
||||
local checkbox = self.druid:new_checkbox(nodes[i], function()
|
||||
on_checkbox_click(self, i)
|
||||
end, click_node)
|
||||
|
||||
|
Reference in New Issue
Block a user