Add more events on button (long_tap, repeated_tap, double_tap)

This commit is contained in:
Insality
2020-02-24 23:36:44 +03:00
parent b1fbb7c5bf
commit 162bbd0ed9
6 changed files with 122 additions and 10 deletions

View File

@@ -42,11 +42,14 @@ function init(self)
self.druid = druid.new(self)
init_top_panel(self)
self.page = 1
self.page = 3
main_page.setup_page(self)
text_page.setup_page(self)
button_page.setup_page(self)
scroll_page.setup_page(self)
-- Refresh state
on_control_button(self, 0)
end

View File

@@ -3,15 +3,39 @@ local sprite_change_style = {}
local M = {}
local function usual_callback()
print("Usual callback")
end
local function long_tap_callback()
print("Long tap callback")
end
local function repeated_callback(self, params, button)
print("Repeated callback", button.click_in_row)
end
local function double_tap_callback(self, params, button)
print("Double tap callback", button.click_in_row)
end
local function setup_buttons(self)
self.druid:new_button("button_usual/button")
self.druid:new_button("button_usual/button", usual_callback)
local custom_style = self.druid:new_button("button_custom_style/button")
local custom_style = self.druid:new_button("button_custom_style/button", usual_callback)
custom_style:set_style(sprite_change_style)
-- HOVER_IMAGE and DEFAULT_IMAGE - from our custom style params
custom_style.HOVER_IMAGE = "button_yellow"
custom_style.DEFAULT_IMAGE = "button_blue"
self.druid:new_button("button_long_tap/button", usual_callback)
.on_long_click:subscribe(long_tap_callback)
self.druid:new_button("button_repeated_tap/button", usual_callback)
.on_repeated_click:subscribe(repeated_callback)
self.druid:new_button("button_double_tap/button", usual_callback)
.on_double_click:subscribe(double_tap_callback)
end