Add druid events in components

This commit is contained in:
Insality
2020-02-24 09:34:16 +03:00
parent a81d49de9d
commit ac2bbc29d3
15 changed files with 1019 additions and 32 deletions

View File

@@ -1,6 +1,7 @@
--- Component to handle back key (android, backspace)
-- @module druid.back_handler
local Event = require("druid.event")
local const = require("druid.const")
local component = require("druid.component")
@@ -15,6 +16,8 @@ local M = component.create("back_handler", { const.ON_INPUT })
function M.init(self, callback, params)
self.callback = callback
self.params = params
self.on_back = Event(callback)
end
@@ -24,7 +27,7 @@ end
-- @tparam table action on_input action
function M.on_input(self, action_id, action)
if action_id == const.ACTION_BACK and action[const.RELEASED] then
self.callback(self:get_context(), self.params)
self.on_back:trigger(self:get_context(), self.params)
return true
end