mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 10:27:47 +02:00
73 lines
1.9 KiB
Lua
73 lines
1.9 KiB
Lua
local druid = require("druid.druid")
|
|
local const = require("druid.const")
|
|
|
|
|
|
local function click_callback(self, text, some)
|
|
print("Button tap callback:", text, some)
|
|
end
|
|
|
|
|
|
local function trigger_callback(self, params)
|
|
msg.post(".", const.ON_MESSAGE_INPUT, {
|
|
node_id = params.node_id,
|
|
action = params.action
|
|
})
|
|
end
|
|
|
|
|
|
function init(self)
|
|
self.druid = druid.new(self)
|
|
|
|
self.button_left = self.druid:new_button("button_left/button", click_callback)
|
|
self.button_left.on_long_click:subscribe(function() print("long click") end)
|
|
self.button_left.on_double_click:subscribe(function() print("double click") end)
|
|
self.button_left.on_repeated_click:subscribe(function() print("repeated_click") end)
|
|
|
|
self.button_right = self.druid:new_button("button_right/button", click_callback)
|
|
|
|
self.druid:new_button("button_trigger_left/button", trigger_callback, {
|
|
node_id = "button_left/button",
|
|
action = const.MESSAGE_INPUT.BUTTON_CLICK
|
|
})
|
|
|
|
self.druid:new_button("button_trigger_left_double/button", trigger_callback, {
|
|
node_id = "button_left/button",
|
|
action = const.MESSAGE_INPUT.BUTTON_DOUBLE_CLICK
|
|
})
|
|
|
|
self.druid:new_button("button_trigger_left_long/button", trigger_callback, {
|
|
node_id = "button_left/button",
|
|
action = const.MESSAGE_INPUT.BUTTON_LONG_CLICK
|
|
})
|
|
|
|
self.druid:new_button("button_trigger_left_repeated/button", trigger_callback, {
|
|
node_id = "button_left/button",
|
|
action = const.MESSAGE_INPUT.BUTTON_REPEATED_CLICK
|
|
})
|
|
|
|
self.druid:new_button("button_trigger_right/button", trigger_callback, {
|
|
node_id = "button_right/button",
|
|
action = const.MESSAGE_INPUT.BUTTON_CLICK
|
|
})
|
|
end
|
|
|
|
|
|
function final(self)
|
|
self.druid:final()
|
|
end
|
|
|
|
|
|
function update(self, dt)
|
|
self.druid:update(dt)
|
|
end
|
|
|
|
|
|
function on_message(self, message_id, message, sender)
|
|
self.druid:on_message(message_id, message, sender)
|
|
end
|
|
|
|
|
|
function on_input(self, action_id, action)
|
|
return self.druid:on_input(action_id, action)
|
|
end
|