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, params) end local function set_random_text_callback(self, params) params.value = "Value: " .. math.random(0, 99) trigger_callback(self, params) end function init(self) self.druid = druid.new(self) self.button_test = self.druid:new_button("button_test/button", click_callback) self.button_test.on_long_click:subscribe(function() print("long click") end) self.button_test.on_double_click:subscribe(function() print("double click") end) self.button_test.on_repeated_click:subscribe(function() print("repeated_click") end) self.druid:new_text("text_random") self.druid:new_button("button_trigger_click/button", trigger_callback, { node_id = "button_test/button", action = const.MESSAGE_INPUT.BUTTON_CLICK }) self.druid:new_button("button_trigger_double/button", trigger_callback, { node_id = "button_test/button", action = const.MESSAGE_INPUT.BUTTON_DOUBLE_CLICK }) self.druid:new_button("button_trigger_long/button", trigger_callback, { node_id = "button_test/button", action = const.MESSAGE_INPUT.BUTTON_LONG_CLICK }) self.druid:new_button("button_trigger_repeated/button", trigger_callback, { node_id = "button_test/button", action = const.MESSAGE_INPUT.BUTTON_REPEATED_CLICK }) self.druid:new_button("button_text_random/button", set_random_text_callback, { node_id = "text_random", action = const.MESSAGE_INPUT.TEXT_SET }) 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