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

边栏推荐
- Pytorch---使用Pytorch实现LinkNet进行语义分割
- PermissionError: [Errno 13] Permission denied: ‘data.csv‘
- Idea case shortcut
- word中插入圖片後,圖片上方有一空行,且删除後布局變亂
- 强化学习-学习笔记2 | 价值学习
- 字节测试工程师十年经验直击UI 自动化测试痛点
- Some suggestions for interface design
- How does the computer save web pages to the desktop for use
- 记一次重复造轮子(Obsidian 插件设置说明汉化)
- Record the online bug solving list (unfinished to be continued 7/4)
猜你喜欢

Win11系统wifi总掉线怎么办?Win11系统wifi总掉线的解决方法
Understand the reading, writing and creation of files in go language

【1200. 最小絕對差】

Hands on deep learning (III) -- convolutional neural network CNN

接口设计时的一些建议

How to solve the problem that win11 cannot write the value to the registry key?

See how Tencent does interface automation testing

分析伦敦银走势图的技巧

idea配置标准注释

托管式服务网络:云原生时代的应用体系架构进化
随机推荐
电脑页面不能全屏怎么办?Win11页面不能全屏的解决方法
See how Tencent does interface automation testing
Golang中UTF编码和字符集
实操自动生成接口自动化测试用例
伦敦银走势图分析的新方法
网络命名空间
After inserting a picture into word, there is a blank line above the picture, and the layout changes after deletion
What if the computer page cannot be full screen? The solution of win11 page cannot be full screen
LeetCode 7. Integer inversion
【1200. 最小绝对差】
九齐NY8B062D MCU规格书/datasheet
Practical examples of node strong cache and negotiation cache
idea大小写快捷键
Practice examples to understand JS strong cache negotiation cache
Flet教程之 07 PopupMenuButton基础入门(教程含源码)
ACM组合计数入门
Cdga | six principles that data governance has to adhere to
记一次重复造轮子(Obsidian 插件设置说明汉化)
go语言笔记(2)go一些简单运用
卷积神经网络在深度学习中新发展的5篇论文推荐