Skip to content

Why does Actor.onTouchEvent{} ignore touchDragged events? #467

Answered by czyzby
DLochmelis33 asked this question in Q&A
Discussion options

You must be logged in to vote

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()
  }
  …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by DLochmelis33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants