@Override
public boolean onGenericMotionEvent(MotionEvent event) {
//The input source is a pointing device associated with a display.
//输入源为可显示的指针设备,如:mouse pointing device(鼠标指针),stylus pointing device(尖笔设备)
if (0 != (event.getSource() & InputDevice.SOURCE_CLASS_POINTER)) {
switch (event.getAction()) {
// process the scroll wheel movement...处理滚轮事件
case MotionEvent.ACTION_SCROLL:
//获得垂直坐标上的滚动方向,也就是滚轮向下滚
if (event.getAxisValue(MotionEvent.AXIS_VSCROLL) < 0.0f) {
LogUtils.d("fortest::onGenericMotionEvent down");
}
//获得垂直坐标上的滚动方向,也就是滚轮向上滚
else {
LogUtils.i("fortest::onGenericMotionEvent up");
}
return true;
}
}
return super.onGenericMotionEvent(event);
}
android鼠标滚轮事件监听方法
王的备忘录2023-10-26 13:03
相关推荐
人道领域5 分钟前
【0-1的agent进阶篇】Prompt 与上下文工程爱笑鱼24 分钟前
Handler(二):MessageQueue 为什么不是普通队列?KINGSEA_16828 分钟前
AgentScope Java 2.0 架构解析阿巴斯甜37 分钟前
Android Studio 新版 Logcat折哥的程序人生 · 物流技术专研1 小时前
Java 23 种设计模式:从踩坑到精通 | 备忘录模式 —— 快照与撤销,给对象装一个“后悔药”监督者修1 小时前
从零构建 GIS 数据引擎:方案驱动架构的设计与实践ikun_文1 小时前
Java里面异常Exception体系知识点Yoke1 小时前
从零到三端:用 Kotlin Multiplatform + Compose 构建跨平台财务追踪应用不负岁月无痕1 小时前
STL -- C++ 红黑树封装 Map 和 Set小园子的小菜1 小时前
Java核心基础:反射与泛型底层原理及实战用法详解