Event not delivered to listener(事件未传递给侦听器)
问题描述
我有 一个使用 scene2d 的 libgdx 游戏代码> 用于 UI.我有几个带有自己的
ClickListener
的 ImageButton
实例.在某些设备上(目前仅在三星 Galaxy S3 和三星 Galaxy S4 Active 上看到过)存在事件无法传递的问题,除非快速单击两次.
I have a libgdx game that uses scene2d
for the UI. I have several ImageButton
instances with its own ClickListener
. On some devices (only seen it on Samsung Galaxy S3 and Samsung Galaxy S4 Active so far) there is a problem with the event not being delivered unless one clicks twice quickly.
每次点击失败都会记录如下内容:
Every time a click fails something like the following is logged:
04-22 16:10:09.678: D/InputReader(728): Input event: value=1 when=20897610551000
04-22 16:10:09.678: I/InputReader(728): Touch event's action is 0x0 (deviceType=0) [pCnt=1, s=0.889 ] when=20897610612000
04-22 16:10:09.678: I/InputDispatcher(728): Delivering touch to: action: 0x0
04-22 16:10:09.678: I/InputDispatcher(728): Delivering touch to: action: 0x3
04-22 16:10:09.688: W/InputEventReceiver(728): Attempted to finish an input event but the input event receiver has already been disposed.
04-22 16:10:09.688: W/InputEventReceiver(728): Attempted to finish an input event but the input event receiver has already been disposed.
04-22 16:10:09.688: V/WindowManager(728): Window{43478730 u0 Keyguard}mOrientationRequetedFromKeyguard=false
04-22 16:10:09.698: D/STATUSBAR-StatusBarManagerService(728): manageDisableList what=0x0 pkg=WindowManager.LayoutParams
04-22 16:10:09.788: D/InputReader(728): Input event: value=0 when=20897720902000
04-22 16:10:09.788: I/InputReader(728): Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=] when=20897720902000
我假设语句 Attempted to finish an input event 但输入事件接收器已被释放. 是这里的关键,但我真的不明白为什么再单击一次它会起作用时间很快.
I assume the statement Attempted to finish an input event but the input event receiver has already been disposed. is key here, but I can't really see why it would work when one click one more time quickly.
这可能是什么原因?我怎样才能进一步调试它以深入了解它?有什么线索吗?
What could the reason for this be? How can I debug this further to get to the bottom of this? Any clues?
除了最后两个之外的所有日志行都出现在 touch down 时,而最后两个出现在 touch up 时.我的事件监听器用于点击.
All log lines except the two last ones appears on touch down, while the last two appears on touch up. My event listener is for on click.
推荐答案
我找到了导致问题的原因.我遇到了 KitKat 中的音量按钮错误的问题,并且有添加了变通方法的变体(https://stackoverflow.com/a/21253443/467650、https://plus.google.com/+MichaelLeahy/posts/CqSCP653UrW).
I found out what was causing the problem. I had issues with the volume button bug in KitKat and had added a variant of the workarounds (https://stackoverflow.com/a/21253443/467650, https://plus.google.com/+MichaelLeahy/posts/CqSCP653UrW).
我能够通过减少运行删除导航栏的处理程序之前的时间延迟来解决我的双点触摸"问题,但是这对于 KitKat 来说还是不够好.我当然可以检查运行该应用程序的 Android 版本,但由于解决方法一开始真的很麻烦,所以我将其全部删除.
I was able to get around my "double touch" problem by decreasing the time delay before running the handler that removes the navigation bar, but that again didn't work well enough with KitKat. I could of course check the Android version of the running the app, but as the workaround is really hacky to begin with I removed it all together.
这篇关于事件未传递给侦听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:事件未传递给侦听器
基础教程推荐
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01