Druid-Extension/druid/templates/widget_full.lua.template
2025-04-19 18:03:50 +03:00

28 lines
751 B
Plaintext

---This is a template for a {COMPONENT_NAME} Druid widget.
---Instantiate this template with `druid.new_widget(widget_module, [template_id], [nodes])`.
---Read more about Druid Widgets here: ...
---@class widget.{COMPONENT_TYPE}: druid.widget
local M = {}
function M:init()
-- Now we have next functions to use here:
-- self:get_node([node_id]) -- Get node inside widget by id
-- self.druid to access Druid Instance API, like:
-- self.druid:new_button([node_id], [callback])
-- self.druid:new_text([node_id], [text])
-- And all functions from component.lua file
self.root = self:get_node("root")
self.button = self.druid:new_button("button", self.on_button, self)
end
function M:on_button()
print("Root node", self.root)
end
return M