mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 10:27:47 +02:00
add android_back component (#5)
This commit is contained in:
parent
5709975ed4
commit
5e2dc34437
@ -1,11 +1,30 @@
|
||||
local data = require("druid.data")
|
||||
|
||||
local M = {}
|
||||
|
||||
M.interest = {
|
||||
data.ON_INPUT
|
||||
}
|
||||
|
||||
|
||||
function M.init(instance, params)
|
||||
-- TODO: first arg store as node. Find way to escape this
|
||||
local callback = instance.node
|
||||
instance.event = data.A_ANDR_BACK
|
||||
instance.callback = callback
|
||||
instance.params = params
|
||||
end
|
||||
|
||||
|
||||
--- input handler
|
||||
-- @param action_id - input action id
|
||||
-- @param action - input action
|
||||
function M.on_input(instance, action_id, action)
|
||||
instance.callback(instance.parent.parent)
|
||||
if action[data.RELEASED] then
|
||||
instance.callback(instance.parent.parent, instance.params)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
|
@ -9,9 +9,9 @@ local STRING = "string"
|
||||
local components = {
|
||||
-- basic
|
||||
button = require("druid.base.button"),
|
||||
android_back = require("druid.base.android_back"),
|
||||
text = require("druid.base.text"),
|
||||
timer = require("druid.base.timer"),
|
||||
-- android_back = require("druid.base.android_back"),
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,6 +30,11 @@ function init(self)
|
||||
print("On button 3")
|
||||
end)
|
||||
|
||||
|
||||
self.druid:new_android_back(function(self, params)
|
||||
print("On android back", params)
|
||||
end, 2)
|
||||
|
||||
self.druid:new_text("text_2", "Simple text")
|
||||
self.druid:new_text("text_3", "locale_text", true)
|
||||
|
||||
@ -37,7 +42,6 @@ function init(self)
|
||||
print("On timer end")
|
||||
end)
|
||||
|
||||
|
||||
end
|
||||
|
||||
function update(self, dt)
|
||||
|
@ -1,3 +1,11 @@
|
||||
key_trigger {
|
||||
input: KEY_BACKSPACE
|
||||
action: "back"
|
||||
}
|
||||
key_trigger {
|
||||
input: KEY_BACK
|
||||
action: "back"
|
||||
}
|
||||
mouse_trigger {
|
||||
input: MOUSE_BUTTON_1
|
||||
action: "touch"
|
||||
|
Loading…
x
Reference in New Issue
Block a user