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

边栏推荐
猜你喜欢

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

FS8B711S14电动红酒开瓶器单片机IC方案开发专用集成IC

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

Reinforcement learning - learning notes 2 | value learning

Flet教程之 05 OutlinedButton基础入门(教程含源码)
![[ismb2022 tutorial] the picture shows the precision medicine of learning. Marinka zitnik, Harvard University, keynote speaker, with 87 ppt](/img/0d/aa7f82fada743ea2ec23355ef954df.jpg)
[ismb2022 tutorial] the picture shows the precision medicine of learning. Marinka zitnik, Harvard University, keynote speaker, with 87 ppt

太方便了,钉钉上就可完成代码发布审批啦!

Jiuqi ny8b062d MCU specification /datasheet
![[in-depth learning] review pytoch's 19 loss functions](/img/c1/07650a6755d5c64ebf8ce370456fb7.png)
[in-depth learning] review pytoch's 19 loss functions

Flet tutorial 04 basic introduction to filledtonalbutton (tutorial includes source code)
随机推荐
WinCC7.5 SP1如何通过交叉索引来寻找变量及其位置?
阿里测试师用UI自动化测试实现元素定位
Managed service network: application architecture evolution in the cloud native Era
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
Fleet tutorial 08 introduction to AppBar toolbar Basics (tutorial includes source code)
Hash哈希竞猜游戏系统开发如何开发丨哈希竞猜游戏系统开发(多套案例)
【1200. 最小绝对差】
jekins初始化密码没有或找不到
idea配置标准注释
How does win11 search for wireless displays? Win11 method of finding wireless display device
《动手学深度学习》(三) -- 卷积神经网络 CNN
栈:如何实现有效括号的判断?
HMS Core 统一扫码服务
mysql语句执行详解
【深度学习】一文看尽Pytorch之十九种损失函数
【服务器数据恢复】某品牌服务器存储raid5数据恢复案例
看腾讯大老如何做接口自动化测试
企业数字化转型最佳实践案例:基于云的数字化平台系统安全措施简介与参考
Summary of the mistakes in the use of qpainter in QT gobang man-machine game
LeetCode+ 81 - 85 单调栈专题