Why does Actor.onTouchEvent{} ignore touchDragged events? #467
-
In the implementation there's a listener with only |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Judging by the documentation and other available methods, this is the expected behavior. The method is not supposed to handle all touch events, just the start and end ones. As for examples of handling events in Kotlinesque style, I think the whole file you linked serves as a good example of how you can approach this. I haven't verified it in IDE, but an event handler utility specific to dragging events would look somewhat like this: inline fun <T : Actor> T.onTouchDragged(crossinline listener: T.() -> Unit): InputListener {
val inputListener = object : KtxInputListener() {
override fun touchDragged(event: InputEvent, x: Float, y: Float, pointer: Int, button: Int) = listener()
}
addListener(inputListener)
return inputListener
} See the |
Beta Was this translation helpful? Give feedback.
Judging by the documentation and other available methods, this is the expected behavior. The method is not supposed to handle all touch events, just the start and end ones. As for examples of handling events in Kotlinesque style, I think the whole file you linked serves as a good example of how you can approach this. I haven't verified it in IDE, but an event handler utility specific to dragging events would look somewhat like this: