跳到主要内容

Activator 事件回调消息

声明​

thread.register_event("xxtouch.activator_callback", function(val)
local ret = json.decode(val)
sys.toast("mode:"..ret.mode.."\n"
.."event:"..ret.event.."\n"
.."time:"..ret.time)
end)

状态​

  • val
    • 配置了 Activator 回调并触发相应事件时,事件详情会传递到此回调

说明​

需要安装 Activator 并在其中完成相应配置后配合使用

示例​

-- 清空消息队列
proc_queue_clear("xxtouch.activator_callback")
--
-- 开始建立监听回调
local eid = thread.register_event("xxtouch.activator_callback", function(val)
local ret = json.decode(val)
if ret.event=="libactivator.statusbar.tap.double" then
sys.toast("双击状态栏回调")
end
end)
--
sys.msleep(20000) -- 等待 20 秒
--
-- 反注册回调函数,如果不反注册监听,那么脚本不会在此结束
thread.unregister_event("xxtouch.activator_callback", eid)

注:上述代码中使用了非本章函数 sys.toast、sys.msleep、proc_queue_clear、thread.register_event、thread.unregister_event