mirror of
https://github.com/Insality/druid.git
synced 2025-09-27 18:12:19 +02:00
Add more events on button (long_tap, repeated_tap, double_tap)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user