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

边栏推荐
- Jiuqi ny8b062d MCU specification /datasheet
- What if the win11 shared file cannot be opened? The solution of win11 shared file cannot be opened
- Flet教程之 07 PopupMenuButton基础入门(教程含源码)
- idea插件
- In the face of the same complex test task, why can the elder sort out the solution quickly? Ali's ten-year test engineers showed their skills
- LeetCode 871. 最低加油次数
- 哈希(Hash)竞猜游戏系统开发功能分析及源码
- 工厂从自动化到数字孪生,图扑能干什么?
- Android原生数据库的基本使用和升级
- 最长的可整合子数组的长度
猜你喜欢

电脑怎么保存网页到桌面上使用

HWiNFO硬件检测工具v7.26绿色版

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

Automatic generation of interface automatic test cases by actual operation

hash 表的概念及应用

What if the brightness of win11 is locked? Solution to win11 brightness locking

What should I do if my computer sharing printer refuses access

Reinforcement learning - learning notes 2 | value learning

Golang中UTF编码和字符集

看腾讯大老如何做接口自动化测试
随机推荐
Length of the longest integrable subarray
go笔记(1)go语言介绍以及特点
PermissionError: [Errno 13] Permission denied: ‘data.csv‘
易周金融 | Q1保险行业活跃人数8688.67万人 19家支付机构牌照被注销
LeetCode 871. Minimum refueling times
[server data recovery] a case of RAID5 data recovery stored in a brand of server
vim异步问题
Managed service network: application architecture evolution in the cloud native Era
电脑共享打印机拒绝访问要怎么办
多模输入事件分发机制详解
Form组件常用校验规则-1(持续更新中~)
go笔记(3)Go语言fmt包的用法
Redis分布式锁的实现
MySQL - database query - use of aggregate function, aggregate query, grouping query
word中插入图片后,图片上方有一空行,且删除后布局变乱
From automation to digital twins, what can Tupo do?
Vue cleans up the keepalive cache scheme in a timely manner
ACM组合计数入门
js 闭包
科普达人丨一文看懂阿里云的秘密武器“神龙架构”