Skip to content

Touch vs Mouse

John Galvin edited this page Oct 26, 2024 · 11 revisions

A Touch Event and a Mouse Event are not same event.


What is the difference?

This is one of the hardest things to grasp when moving from a desktop development to mobile, is the understanding that there is no such thing as a "mouse" in the mobile development world. There are only touch events and unlike mouse events, touch events do not maintain state.

And that's it in a nutshell...

Take noted:

  • There is no concept of a Left button events (i.e. Click, Down, Up etc)
  • There is no concept of a Right button events (i.e. Click, Down, Up etc)
  • There is no concept of Mouse Location Events (Hover etc)

So how do we use Touch Events?

The good news is, a single touch event, olc::GetTouch() , can be likened to a olc::GetMouse(0) which means your simple fire and forget code will work the very same.

For example:

  • olc::GetTouch().bPressed can be executed the same as olc::GetMouse(0).bPressed
  • olc::GetTouch().bHeld can be executed the same as olc::GetMouse(0).bHeld
  • olc::GetTouch().bReleased can be executed the same as olc::GetMouse(0).bReleased
Clone this wiki locally