mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +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 = {}
|
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
|
--- input handler
|
||||||
-- @param action_id - input action id
|
-- @param action_id - input action id
|
||||||
-- @param action - input action
|
-- @param action - input action
|
||||||
function M.on_input(instance, action_id, 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
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -9,9 +9,9 @@ local STRING = "string"
|
|||||||
local components = {
|
local components = {
|
||||||
-- basic
|
-- basic
|
||||||
button = require("druid.base.button"),
|
button = require("druid.base.button"),
|
||||||
|
android_back = require("druid.base.android_back"),
|
||||||
text = require("druid.base.text"),
|
text = require("druid.base.text"),
|
||||||
timer = require("druid.base.timer"),
|
timer = require("druid.base.timer"),
|
||||||
-- android_back = require("druid.base.android_back"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,6 +30,11 @@ function init(self)
|
|||||||
print("On button 3")
|
print("On button 3")
|
||||||
end)
|
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_2", "Simple text")
|
||||||
self.druid:new_text("text_3", "locale_text", true)
|
self.druid:new_text("text_3", "locale_text", true)
|
||||||
|
|
||||||
@ -37,7 +42,6 @@ function init(self)
|
|||||||
print("On timer end")
|
print("On timer end")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function update(self, dt)
|
function update(self, dt)
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
key_trigger {
|
||||||
|
input: KEY_BACKSPACE
|
||||||
|
action: "back"
|
||||||
|
}
|
||||||
|
key_trigger {
|
||||||
|
input: KEY_BACK
|
||||||
|
action: "back"
|
||||||
|
}
|
||||||
mouse_trigger {
|
mouse_trigger {
|
||||||
input: MOUSE_BUTTON_1
|
input: MOUSE_BUTTON_1
|
||||||
action: "touch"
|
action: "touch"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user