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

边栏推荐
- 扩展你的KUBECTL功能
- What is the development of block hash quiz game system? Hash quiz game system development (case mature)
- Advantages of semantic tags and block level inline elements
- 测试用例 (TC)
- 哈希表、哈希函数、布隆过滤器、一致性哈希
- LeetCode 871. Minimum refueling times
- RFID仓库管理系统解决方案有哪些功能模块
- Flet教程之 07 PopupMenuButton基础入门(教程含源码)
- The concept and application of hash table
- 卷积神经网络在深度学习中新发展的5篇论文推荐
猜你喜欢
Win11亮度被锁定怎么办?Win11亮度被锁定的解决方法
实操自动生成接口自动化测试用例
Ten years' experience of byte test engineer directly hits the pain point of UI automation test
Qt五子棋人机对战画棋子之QPainter的使用误区总结
WinCC7.5 SP1如何通过交叉索引来寻找变量及其位置?
What if the WiFi of win11 system always drops? Solution of WiFi total drop in win11 system
Flet tutorial 06 basic introduction to textbutton (tutorial includes source code)
【1200. 最小絕對差】
Win11怎么搜索无线显示器?Win11查找无线显示器设备的方法
Reinforcement learning - learning notes 2 | value learning
随机推荐
Android原生数据库的基本使用和升级
哈希表、哈希函数、布隆过滤器、一致性哈希
LeetCode+ 81 - 85 单调栈专题
WinCC7.5 SP1如何通过交叉索引来寻找变量及其位置?
GVM use
Go notes (1) go language introduction and characteristics
Win11U盘拒绝访问怎么办?Win11U盘拒绝访问的有效解决方法
LeetCode 8. String conversion integer (ATOI)
浏览器渲染页面过程
Flet tutorial 07 basic introduction to popupmenubutton (tutorial includes source code)
Fleet tutorial 08 introduction to AppBar toolbar Basics (tutorial includes source code)
Qt五子棋人机对战画棋子之QPainter的使用误区总结
LeetCode 8. 字符串转换整数 (atoi)
Flet教程之 05 OutlinedButton基础入门(教程含源码)
NetCore3.1 Json web token 中间件
福昕PDF编辑器v10.1.8绿色版
Vue cleans up the keepalive cache scheme in a timely manner
CDGA|数据治理不得不坚持的六个原则
LeetCode 7. 整数反转
LeetCode 871. Minimum refueling times