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

边栏推荐
- 【服务器数据恢复】某品牌服务器存储raid5数据恢复案例
- Win11U盘拒绝访问怎么办?Win11U盘拒绝访问的有效解决方法
- RFID仓库管理系统解决方案有哪些功能模块
- Flet tutorial 06 basic introduction to textbutton (tutorial includes source code)
- Go language notes (2) some simple applications of go
- Remember to build wheels repeatedly at one time (the setting instructions of obsidian plug-in are translated into Chinese)
- Flet tutorial 07 basic introduction to popupmenubutton (tutorial includes source code)
- 工厂从自动化到数字孪生,图扑能干什么?
- go语言笔记(4)go常用管理命令
- 实操自动生成接口自动化测试用例
猜你喜欢

MySQL --- 数据库查询 - 聚合函数的使用、聚合查询、分组查询
![[observation] Lenovo: 3x (1+n) smart office solution, releasing the](/img/e4/f660461c42eb81ab8c94fd87503a83.png)
[observation] Lenovo: 3x (1+n) smart office solution, releasing the "multiplier effect" of office productivity

Quelques suggestions pour la conception de l'interface

What if win11u disk refuses access? An effective solution to win11u disk access denial
Practice examples to understand JS strong cache negotiation cache

6月“墨力原创作者计划”获奖名单公布!邀您共话国产数据库

【服务器数据恢复】某品牌服务器存储raid5数据恢复案例

字节测试工程师十年经验直击UI 自动化测试痛点

uniapp 富文本编辑器使用

hash 表的概念及应用
随机推荐
Record the online bug solving list (unfinished to be continued 7/4)
After inserting a picture into word, there is a blank line above the picture, and the layout changes after deletion
What if the brightness of win11 is locked? Solution to win11 brightness locking
GVM使用
How does wincc7.5 SP1 find variables and their positions through cross indexing?
tcp为啥是三次握手和四次挥手
go笔记(1)go语言介绍以及特点
接口設計時的一些建議
Idea case shortcut
Flet tutorial 07 basic introduction to popupmenubutton (tutorial includes source code)
HWiNFO硬件检测工具v7.26绿色版
卷积神经网络在深度学习中新发展的5篇论文推荐
LeetCode 871. 最低加油次数
word中使用自动插入题注功能
What should I do if my computer sharing printer refuses access
What is the development of block hash quiz game system? Hash quiz game system development (case mature)
阿里云国际版CDN的优势
idea恢复默认快捷键
实操自动生成接口自动化测试用例
Win11无法将值写入注册表项如何解决?