mirror of
https://github.com/Insality/druid.git
synced 2025-09-27 10:02:18 +02:00
Update editor scripts
This commit is contained in:
9
druid/templates/widget.lua.template
Normal file
9
druid/templates/widget.lua.template
Normal file
@@ -0,0 +1,9 @@
|
||||
---@class widget.{COMPONENT_TYPE}: druid.widget
|
||||
local M = {}
|
||||
|
||||
|
||||
function M:init()
|
||||
end
|
||||
|
||||
|
||||
return M
|
27
druid/templates/widget_full.lua.template
Normal file
27
druid/templates/widget_full.lua.template
Normal file
@@ -0,0 +1,27 @@
|
||||
---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
|
Reference in New Issue
Block a user