当前位置:网站首页>多模輸入事件分發機制詳解
多模輸入事件分發機制詳解
2022-07-04 21:00: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");// 取消監聽後,軟鍵盤默認都彈出

边栏推荐
- word中插入图片后,图片上方有一空行,且删除后布局变乱
- How does win11 search for wireless displays? Win11 method of finding wireless display device
- LeetCode 871. 最低加油次数
- 【1200. 最小絕對差】
- tcp为啥是三次握手和四次挥手
- Après l'insertion de l'image dans le mot, il y a une ligne vide au - dessus de l'image, et la disposition est désordonnée après la suppression
- Flet教程之 06 TextButton基础入门(教程含源码)
- BFC interview Brief
- Play the music of youth
- Win11怎么搜索无线显示器?Win11查找无线显示器设备的方法
猜你喜欢

RFID仓储管理系统解决方案的优点

Flet tutorial 04 basic introduction to filledtonalbutton (tutorial includes source code)

What if the WiFi of win11 system always drops? Solution of WiFi total drop in win11 system

【1200. 最小绝对差】

How does win11 search for wireless displays? Win11 method of finding wireless display device

五子棋 上班摸鱼工具 可局域网/人机

剑指 Offer II 80-100(持续更新)

《动手学深度学习》(三) -- 卷积神经网络 CNN

Ten years' experience of byte test engineer directly hits the pain point of UI automation test

Form组件常用校验规则-1(持续更新中~)
随机推荐
go语言笔记(4)go常用管理命令
go笔记(1)go语言介绍以及特点
Remember to build wheels repeatedly at one time (the setting instructions of obsidian plug-in are translated into Chinese)
Implementation of redis distributed lock
JS closure
Win11无法将值写入注册表项如何解决?
PermissionError: [Errno 13] Permission denied: ‘data.csv‘
Qt五子棋人机对战画棋子之QPainter的使用误区总结
LeetCode 871. 最低加油次数
WinCC7.5 SP1如何通过交叉索引来寻找变量及其位置?
Flet教程之 06 TextButton基础入门(教程含源码)
Vue cleans up the keepalive cache scheme in a timely manner
【1200. 最小绝对差】
Fleet tutorial 08 introduction to AppBar toolbar Basics (tutorial includes source code)
阿里测试师用UI自动化测试实现元素定位
Browser render page pass
阿里云国际版CDN的优势
【服务器数据恢复】某品牌服务器存储raid5数据恢复案例
go笔记(3)Go语言fmt包的用法
Flet tutorial 05 outlinedbutton basic introduction (tutorial includes source code)