korge
korge copied to clipboard
Android device: onClick event is about previous click
Developing an app based on https://github.com/korlibs/korge-hello-world I noticed that sometimes touching a view on a physical Android device doesn't work (not shown in onClick event of the view), Then I found out that next touch of another view results in onClick event of previously touched view. And so on: on a touch previous event appears. The same problem on my Android 7 and 11 physical devices.
This problem doesn't occur on Android emulators (and on JVM), where I use PC's mouse to "touch" that views.
The problem is easily reproduced and traced using statements like this:
Console.log("Logo clicked")
I understand that korlibs v.1.* on which current version of korge-hello-world is based, aren't fixed anymore, so I'm waiting for the korge-hello-world to be updated to use KorGe 2.0, so I will reproduce (or not) the problem there.
For the reference, my app is this: https://github.com/andstatus/game2048 , the same problem is reproduced in the sample app https://github.com/RezMike/2048
@soywiz Thank you for updating Korge Gradle plugin, I updated my app to KorGe 2.0.0-rc2 and see that "onClick" behavior on Android device somewhat changed; but it still doesn't work properly.
Now I see problems with Windows X64 build also: both mouse clicks and keyboard key don't work properly: On mouse clicks: wrong buttons receive events. On keyboard key press: app receives 4 the same key events.
@soywiz Please see above link to the commit of my app.
Just to emphasize importance of the fix for the bug:
This is the most critical bug in KorGe for my app. Working it around makes UX sufficiently worse. In Android it is so bad that I have to MOVE buttons on button bars after each User's tap only because tapping the second time on the same place of the screen doesn't work (even after a fix at an app side).
@soywiz You may laugh but after upgrade from Korge v.2.1.1 to 2.4.7. I see the regression: on an Android device during User's taps on a screen (not during mouse "clicks" on an emulator!): onClick event is about previous click. Again, like a year ago :-)
This time I found another workaround for the bug: I replaced onClick mouse event with singleTouch { tap } event For me the "tap" event works exactly the same as onClick, but on a touch screen it doesn't have the bug. So far I tested this:
- On physical Android touch screen: taps by fingers.
- On Android emulator and on JVM: clicks by physical mouse of my PC.
See a commit above.
Note: the bug is still present in a master branch of korge-next repo.
Another noticeable difference between "tap" event and "onClick" on an Android device: my app's buttons that use "tap" event are much more responsive than when I used onClick event (even when it worked "normally"). I mean at last buttons in my app work as fast as buttons in other Android apps :-)
@soywiz Thank you for developing the Korge libraries!
Click was handled somehow with down and up events instead of a real event from the OS. IIRC that was done to simplify event handling and to support on click on targets like touch devices that doesn't have the concept of click event, also to handle multitouch click events. I don't remember other details, but I have marked this issue to be checked again