My Perspective project (currently stable 8.0.11 (b2020041411)) will primarily use Windows 10 tablets (Microsoft Surface Pro) with touch screens but there is a need for it to be compatible with desktop PCs (mouse clicks) too. Both will use chrome browsers. I need a button on a view to complete the same script whether it is touched or clicked.
I quickly realized that I needed to use the onTouch[something] and onMouse[something] events to distinguish mouse clicks and screen touches on the same button. However, I’ve noticed the mouse[up/down] events firing when touching a button on a touch screen.
To demonstrate, I have made a perspective view with a button and two labels (lblClick and lblTouch).
To the button, I’ve added scripts to the onMouseDown and onMouseUp events to change the lblClick.text prop.
and, I’ve added scripts to the onTouchStart and onTouchEnd events to change the lblTouch.text prop.
In this video of me touching the button you can see the lblClick text value change when I’m using a touch screen.
How do I avoid having the onMouseDown event from triggering?? It sometimes causes the script to run twice (once in onMouseDown and again in onTouchEnd) when button is touched.
In my application the button will be used as a momentary button. When the button is held down a motor moves and when the button is released the motor stops. In some cases when the button is held down the motor moves but when it is released the motor does not stop because the MouseDown event is trigger again, causing the motor to move.