# libgdx(android) touchup triggers more than once?

I have a function I run inside the touchUp method but when I click with the mouse during emulation, it triggers my function multiple times. I don't think its an error with the called method itself because if I put the call in KeyUp then it triggers once as expected.

If it matters I am working in android studio.

• Try to return true after your function call – Arda Kara Aug 18 '15 at 10:19

If you use polling, use Gdx.input.justTouched() rather than Gdx.input.isTouched().

Have you implemented the other methods in InputProcessor?
It seems to me that your touchUp method is called multiple times because perhaps your touchDown and touchDragged are never called correctly.
Be sure to return false in the unused methods if you don't want to use them.
Perhaps you could show us your code snippet.

I will presume you are using InputListener class. Because Input class don't have a touchUp method. You didn't mention this part in your question.

I'll assure you touchUp funciton will not be called twice. You are using an emulator, and in this case touch up function will be triggered by the mouse button. So as long as there is not a second mouse pointer(?), touchUp function is called once per click.

I also will presume you are using only one Listener.

What is happening is touchUp function is not the only function triggered by a mouse click. If you change the position of the mouse while holding it, touchDragged function will also be called. Maybe that's what is confusing you.

Try to put a System.out.println("TOUCH UP"); into your touchUp function to be sure of how many times that function is called. And please don't put it in anywhere else.