mirror of
https://github.com/Insality/druid.git
synced 2025-09-28 10:32:20 +02:00
Resolve #171 #158 Don't need to pass full template name, correct work with inner clone_tree and inner templates
This commit is contained in:
25
example/examples/system/inner_templates/inner_button.lua
Normal file
25
example/examples/system/inner_templates/inner_button.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
local component = require("druid.component")
|
||||
|
||||
---@class inner_button : druid.base_component
|
||||
local InnerButton = component.create("inner_button")
|
||||
|
||||
local SCHEME = {
|
||||
ROOT = "root",
|
||||
BUTTON = "button",
|
||||
TEXT = "text",
|
||||
}
|
||||
|
||||
|
||||
function InnerButton:init(template, nodes)
|
||||
self:set_template(template)
|
||||
self:set_nodes(nodes)
|
||||
self.root = self:get_node(SCHEME.ROOT)
|
||||
self.druid = self:get_druid()
|
||||
|
||||
local value = math.random(0, 99)
|
||||
self.button = self.druid:new_button(SCHEME.BUTTON, function() print(value) end)
|
||||
self.text = self.druid:new_text(SCHEME.TEXT, value)
|
||||
end
|
||||
|
||||
|
||||
return InnerButton
|
Reference in New Issue
Block a user