#鸿蒙通关秘籍#获取TouchEvent中手指的历史触摸点

HarmonyOS
2024-12-05 15:42:43
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
Y影刃XML

为了获取当前帧中所有的历史触摸点,可以在TouchEvent中调用getHistoricalPoints方法,以下是实现的代码:

let historicalPoints = event.getHistoricalPoints();
historicalPoints.forEach((historicalPoint) => {
  let size = historicalPoint.size;
  let force = historicalPoint.force;
  let timestamp = historicalPoint.timestamp;
  // 对历史点数据信息进行处理或日志记录
});
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.

该方法返回一个由HistoricalPoint对象组成的数组,对于每一个历史点,可以通过该对象访问触摸区域大小、压力值和时间戳等信息。

分享
微博
QQ
微信
回复
2024-12-05 16:03:59


相关问题