Jump to content
  • Advertisement
Sign in to follow this  
LAURENT*

Where is onTouchEvent called?

This topic is 535 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I could not find this method called "public Boolean onTouchEvent(MotionEvent event) anywhere in my code. I was wondering where it could be called with no luck. Is this method called automatically? Are all the built in methods than need to be overridden called automatically?

Share this post


Link to post
Share on other sites
Advertisement

You need to provide more framing for your question. I see that you are tagged the post with Android, but are you writing this in straight Java or another game engine?

If you're writing in Java than you have to call and define the onTouchEvent.

Share this post


Link to post
Share on other sites

I'm writing in java sorry about that.

 

I did define "public Boolean onTouchEvent(MotionEvent event)" in an override method but I cannot find where this method is called and executed. I expected to see it in my Mainthread class within my overridden run() method  but it was not there. Now I have a method that I don't understand when and where it is  

 

I know this method is built in and a description says it is called everytime I tap my phones screen but that is not important to me.

Share this post


Link to post
Share on other sites

I know this method is built in and a description says it is called everytime I tap my phones screen but that is not important to me.


Yes it comes from within built in classes and function so you probably wont be able to see exactly how/where it is called. It is called automatically by the system when a touch event occurs. You don't need to do anything more than override that function to receive and respond to the event.

The android developer documentation is pretty handy. See https://developer.android.com/training/gestures/detector.html and https://developer.android.com/reference/android/view/View.html for onTouchEvent descriptions

Share this post


Link to post
Share on other sites

If you put a breakpoint in your onTouchEvent, you should be able to see in your debugger where it is called from, if you are really curious.

You could also download the source code to android, and see exactly how it works.

 

But it is not vital information, as noted above, you can just rely on it being called by the OS/application framework when needed.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!