mirror of
https://github.com/Insality/druid.git
synced 2025-09-27 18:12:19 +02:00
#58 fix get druid instance by name
This commit is contained in:
@@ -92,6 +92,7 @@ function Component.increase_input_priority(self)
|
||||
self._meta.increased_input_priority = true
|
||||
end
|
||||
|
||||
|
||||
--- Reset input priority in current input stack
|
||||
-- @function component:reset_input_priority
|
||||
function Component.reset_input_priority(self)
|
||||
@@ -133,21 +134,23 @@ end
|
||||
-- @treturn Druid Druid instance with component context
|
||||
function Component.get_druid(self)
|
||||
local context = { _context = self }
|
||||
return setmetatable(context, { __index = self:get_context().druid })
|
||||
return setmetatable(context, { __index = self._meta.druid })
|
||||
end
|
||||
|
||||
|
||||
--- Setup component context and his style table
|
||||
-- @function component:setup_component
|
||||
-- @tparam druid_instance table The parent druid instance
|
||||
-- @tparam context table Druid context. Usually it is self of script
|
||||
-- @tparam style table Druid style module
|
||||
-- @treturn Component Component itself
|
||||
function Component.setup_component(self, context, style)
|
||||
function Component.setup_component(self, druid_instance, context, style)
|
||||
self._meta = {
|
||||
template = nil,
|
||||
context = nil,
|
||||
nodes = nil,
|
||||
style = nil,
|
||||
druid = druid_instance,
|
||||
increased_input_priority = false
|
||||
}
|
||||
|
||||
|
@@ -61,7 +61,7 @@ end
|
||||
-- Create the component itself
|
||||
local function create(self, instance_class)
|
||||
local instance = instance_class()
|
||||
instance:setup_component(self._context, self._style)
|
||||
instance:setup_component(self, self._context, self._style)
|
||||
|
||||
table.insert(self.components[const.ALL], instance)
|
||||
|
||||
|
Reference in New Issue
Block a user