当前位置:网站首页>多模输入事件分发机制详解
多模输入事件分发机制详解
2022-07-04 19:46:00 【InfoQ】
一、 多模输入概述
二、输入事件和设备状态数据流介绍

- 输入事件分发过程会优先经过输入事件拦截模块,当有拦截器注册时,输入事件会终止继续上报,相应的拦截器会拦截所有输入事件。该事件拦截特性当前主要支持无障碍模式。
- 当没有拦截器注册时,输入事件会上报给输入事件监听模块,系统级应用(如:系统设置、桌面)通过监听输入事件,支持系统级特性(如:状态栏隐藏/消失等)。
- 事件监听模块对事件的监听不会阻断事件继续上报;支持事件监听的同时,输入事件还会继续上报。
- 对于按键事件会上报给订阅按键分发模块处理,分发给对应的应用处理,事件分发流程结束。
- 其他触摸屏事件和鼠标事件不会经过订阅按键分发模块,会继续上报给应用窗口处理。
三、多模输入事件分发原则
- 如没有鼠标上的按钮按下,当前鼠标指向哪个目标,鼠标输入事件就分发给坐标锁定的目标。
- 如果有鼠标上的按钮按下,以第一个按钮按下时刻鼠标坐标锁定的目标作为分发标的,直到所有的按钮都抬起。
- 触摸屏输入时,将第一个手指按下锁定的目标作为输入事件分发标的,直到所有的手指都抬起。
四、OpenHarmony 3.1版本新增接口说明


- 首先导入模块
// 输入法在软键盘显示逻辑中通过订阅物理键盘的状态:插入/拔出
// 根据isPhysicalkeyboardExist的值决定软键盘是否弹出
...
let isPhysicalkeyboardExist = false;
inputDevice.on("change", (callback) => {
console.log("type: " + callback.type + ", deviceId: " + callback.deviceId);
inputDevice.getDevice(callback.deviceId, (ret) => {
console.log("The keyboard type of the device is: " + ret);
if (ret == keyboard.ALPHABETIC_KEYBOARD && callback.type == 'add') { // 热插拔设备为键盘
isPhysicalkeyboardExist = true;
} else if (ret == keyboard.ALPHABETIC_KEYBOARD && callback.type == 'remove') {
isPhysicalkeyboardExist = false;
}
});
});
...
listener: function(data) {
console.log("type: " + data.type + ", deviceId: " + data.deviceId);
}
// 单独取消listener的监听。
inputDevice.off("change", this.listener);
// 取消所有监听
inputDevice.off("change");// 取消监听后,软键盘默认都弹出

边栏推荐
- NetCore3.1 Json web token 中间件
- 强化学习-学习笔记2 | 价值学习
- 《动手学深度学习》(三) -- 卷积神经网络 CNN
- What if the win11 shared file cannot be opened? The solution of win11 shared file cannot be opened
- Understand Alibaba cloud's secret weapon "dragon architecture" in the article "science popularization talent"
- 【深度学习】一文看尽Pytorch之十九种损失函数
- vim异步问题
- go笔记(1)go语言介绍以及特点
- Ten years' experience of byte test engineer directly hits the pain point of UI automation test
- 电脑共享打印机拒绝访问要怎么办
猜你喜欢

分析伦敦银走势图的技巧

Idea restore default shortcut key

Flet tutorial 06 basic introduction to textbutton (tutorial includes source code)

Form组件常用校验规则-1(持续更新中~)

电脑页面不能全屏怎么办?Win11页面不能全屏的解决方法

【观察】联想:3X(1+N)智慧办公解决方案,释放办公生产力“乘数效应”
![NLP, vision, chip What is the development direction of AI? Release of the outlook report of Qingyuan Association [download attached]](/img/79/82763392e74d102921b4e8e601d4c6.png)
NLP, vision, chip What is the development direction of AI? Release of the outlook report of Qingyuan Association [download attached]
![NLP、视觉、芯片...AI重点方向发展几何?青源会展望报告发布[附下载]](/img/79/82763392e74d102921b4e8e601d4c6.png)
NLP、视觉、芯片...AI重点方向发展几何?青源会展望报告发布[附下载]

What if the win11 shared file cannot be opened? The solution of win11 shared file cannot be opened

伦敦银走势图分析的新方法
随机推荐
JS closure
分析伦敦银走势图的技巧
Common verification rules of form components -1 (continuously updating ~)
看腾讯大老如何做接口自动化测试
LeetCode 7. Integer inversion
RFID仓库管理系统解决方案有哪些功能模块
Flet tutorial 07 basic introduction to popupmenubutton (tutorial includes source code)
LeetCode+ 81 - 85 单调栈专题
[ismb2022 tutorial] the picture shows the precision medicine of learning. Marinka zitnik, Harvard University, keynote speaker, with 87 ppt
Function analysis and source code of hash guessing game system development
AP8022开关电源小家电ACDC芯片离线式开关电源IC
Four traversal methods of binary tree, as well as the creation of binary tree from middle order to post order, pre order to middle order, pre order to post order, and sequence [specially created for t
What is the development of block hash quiz game system? Hash quiz game system development (case mature)
Reinforcement learning - learning notes 2 | value learning
Length of the longest integrable subarray
Alibaba testers use UI automated testing to achieve element positioning
科普达人丨一文看懂阿里云的秘密武器“神龙架构”
Practice examples to understand JS strong cache negotiation cache
Hash quiz game system development how to develop hash quiz game system development (multiple cases)
mysql语句执行详解