Package pyjsdl :: Module event :: Class TouchListener

Class TouchListener

event.touchlistener

Instance Methods
 
__init__(self, canvas)
Touch event listener.
 
activate(self)
 
add_callback(self, callback)
Add callback object to receive touch events. The callback should have methods onTouchStart, onTouchEnd, onTouchMove, and onTouchCancel. Optional callback method onTouchInitiate used to report initial touch event detection. Callback methods will be called with an event argument.
 
is_active(self)
Check if touch event is registered.
Method Details

__init__(self, canvas)
(Constructor)

 

Touch event listener.

Refer to touch event api documentation:
https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent.
Notes:
The event.touches attribute is a list of touch objects. Use len(touches) for touch count and touches.item(<index>) to retrieve touch object. The touch attribute touch.clientX/touch.clientY provides touch position. Position offset checked by display getAbsoluteLeft/getAbsoluteTop/getScrollLeft/getScrollTop. Browser triggers delayed mousedown/mouseup event after touchstart/touchend event.

Module initialization creates pyjsdl.event.touchlistener instance.