当前位置:网站首页>多模输入事件分发机制详解
多模输入事件分发机制详解
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");// 取消监听后,软键盘默认都弹出

边栏推荐
- MySQL statement execution details
- The concept and application of hash table
- 记录线上bug解决list(未完待续7/4)
- Leetcode+ 81 - 85 monotone stack topic
- Advantages of semantic tags and block level inline elements
- 奏响青春的乐章
- js 闭包
- 黄金k线图中的三角形有几种?
- 语义化标签的优势和块级行内元素
- What is the development of block hash quiz game system? Hash quiz game system development (case mature)
猜你喜欢
电脑怎么保存网页到桌面上使用
字节测试工程师十年经验直击UI 自动化测试痛点
精选综述 | 用于白内障分级/分类的机器学习技术
How does win11 search for wireless displays? Win11 method of finding wireless display device
How to solve the problem that win11 cannot write the value to the registry key?
Summary of the mistakes in the use of qpainter in QT gobang man-machine game
ICML 2022 | meta proposes a robust multi-objective Bayesian optimization method to effectively deal with input noise
伦敦银走势图分析的新方法
Idea configuration standard notes
Qt五子棋人机对战画棋子之QPainter的使用误区总结
随机推荐
Qt五子棋人机对战画棋子之QPainter的使用误区总结
阿里云国际版CDN的优势
看腾讯大老如何做接口自动化测试
ICML 2022 | Meta提出鲁棒的多目标贝叶斯优化方法,有效应对输入噪声
E-week finance | Q1 the number of active people in the insurance industry was 86.8867 million, and the licenses of 19 Payment institutions were cancelled
Function analysis and source code of hash guessing game system development
The problem of the maximum difference between the left and right maxima
【ISMB2022教程】图表示学习的精准医疗,哈佛大学Marinka Zitnik主讲,附87页ppt
易周金融 | Q1保险行业活跃人数8688.67万人 19家支付机构牌照被注销
idea大小写快捷键
Go notes (3) usage of go language FMT package
科普达人丨一文看懂阿里云的秘密武器“神龙架构”
word中插入图片后,图片上方有一空行,且删除后布局变乱
NetCore3.1 Json web token 中间件
FS8B711S14电动红酒开瓶器单片机IC方案开发专用集成IC
MySQL statement execution details
Practical examples of node strong cache and negotiation cache
go语言笔记(2)go一些简单运用
acwing 3302. Expression evaluation
MySQL - database query - use of aggregate function, aggregate query, grouping query