摆动式多按钮压力机如何处理? [英] How are multi-button presses handled in swing?

查看:55
本文介绍了摆动式多按钮压力机如何处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用带有摆动功能的手写笔时,我遇到一些奇怪的行为.

我将按下触控笔侧面的按钮(RIGHT)和按下触控笔向下(LEFT)解释为抢劫"事件,但偶尔(通常大于0)事件只是被丢弃.

MouseEvent的JavaDoc非常清楚地说明了一次执行一次(左下,右下,右上,左上)如何处理多按钮按下,但是对于同时按下按钮却一无所知.

我不知道要问,它们是作为两个mousePressed事件发出的,还是作为两个按钮都设置了按钮掩码的事件发出的?还是完全其他?

谢谢.

解决方案

我将API文档解释为根本无法同时按下按钮:

按下多个鼠标按钮时,每次按下,释放和单击都将导致一个单独的事件.

因此,应该是单独的事件.您观察到的问题可能是由于代码,手写笔的驱动程序,硬件或Swing中的错误所致(在我看来,这是按照可能性递减的顺序进行的:)

如果可能,我会尝试通过记录不同级别的事件来诊断问题.

I'm experiencing some strange behaviour when using a stylus with swing.

I am interpreting pressing the button on the side of the stylus(RIGHT) and pressing the stylus down(LEFT) as a "Grab" event, but occasionally (more often than 0), events are just being dropped.

The JavaDocs for MouseEvent are pretty explicit about how multibutton presses are handled if executed one at a time (left down, right down, right up, left up) but say nothing about simultaneous button presses.

I'm left to wonder, would they be emitted as two mousePressed events, or as one with the button mask set for both buttons, or something else entirely?

Thanks.

解决方案

I'd interpret the API doc as simultaneous button presses being simply not possible:

When multiple mouse buttons are pressed, each press, release, and click results in a separate event.

So there should be separate events. The problems you observe could be due to errors in your code, the stylus' driver, the hardware, or Swing (this is in decreasing order of likelihood as I see it :)

I'd try to diagnose the problem by logging events at different levels, if possible.

这篇关于摆动式多按钮压力机如何处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆