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

边栏推荐
- 【服务器数据恢复】某品牌服务器存储raid5数据恢复案例
- 九齐单片机NY8B062D单按键控制4种LED状态
- In the face of the same complex test task, why can the elder sort out the solution quickly? Ali's ten-year test engineers showed their skills
- How to solve the problem that win11 cannot write the value to the registry key?
- 接口设计时的一些建议
- 接口設計時的一些建議
- Understand the reading, writing and creation of files in go language
- HMS Core 机器学习服务
- Flet tutorial 04 basic introduction to filledtonalbutton (tutorial includes source code)
- LeetCode 871. Minimum refueling times
猜你喜欢

Win11无法将值写入注册表项如何解决?

Pytorch---使用Pytorch实现LinkNet进行语义分割

强化学习-学习笔记2 | 价值学习

阿里测试师用UI自动化测试实现元素定位

How does the computer save web pages to the desktop for use

Jiuqi ny8b062d MCU specification /datasheet

精选综述 | 用于白内障分级/分类的机器学习技术

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

Idea restore default shortcut key

How does win11 search for wireless displays? Win11 method of finding wireless display device
随机推荐
最长的可整合子数组的长度
太方便了,钉钉上就可完成代码发布审批啦!
Win11共享文件打不开怎么办?Win11共享文件打不开的解决方法
《动手学深度学习》(三) -- 卷积神经网络 CNN
长城证券开户安全吗 股票开户流程网上开户
黄金k线图中的三角形有几种?
NLP、视觉、芯片...AI重点方向发展几何?青源会展望报告发布[附下载]
Advantages of semantic tags and block level inline elements
Quelques suggestions pour la conception de l'interface
Flet tutorial 07 basic introduction to popupmenubutton (tutorial includes source code)
word中插入图片后,图片上方有一空行,且删除后布局变乱
记录线上bug解决list(未完待续7/4)
CDGA|数据治理不得不坚持的六个原则
See how Tencent does interface automation testing
实操自动生成接口自动化测试用例
Win11U盘拒绝访问怎么办?Win11U盘拒绝访问的有效解决方法
Practice examples to understand JS strong cache negotiation cache
go语言笔记(4)go常用管理命令
接口设计时的一些建议
What if the brightness of win11 is locked? Solution to win11 brightness locking