Blockly. Touch
Properties
TOUCH_ENABLED
Whether touch is enabled in the browser. Copied from Closure's goog.events.BrowserFeature.TOUCH_ENABLED
TOUCH_MAP
Object
The TOUCH_MAP lookup dictionary specifies additional touch events to fire, in conjunction with mouse events.
Methods
checkTouchIdentifier
checkTouchIdentifier(e) returns boolean
Check whether the touch identifier on the event matches the current saved identifier. If there is no identifier, that means it's a mouse event and we'll use the identifier "mouse". This means we won't deal well with multiple mice being used at the same time. That seems okay. If the current identifier was unset, save the identifier from the event. This starts a drag/gesture, during which touch events with other identifiers will be silently ignored.
Parameter |
|
---|---|
e |
Event Mouse event or touch event. Value must not be null. |
- Returns
-
boolean
Whether the identifier on the event matches the current saved identifier.
clearTouchIdentifier
clearTouchIdentifier()
Clear the touch identifier that tracks which touch stream to pay attention to. This ends the current drag/gesture and allows other pointers to be captured.
getTouchIdentifierFromEvent
getTouchIdentifierFromEvent(e) returns string
Get the touch identifier from the given event. If it was a mouse event, the identifier is the string 'mouse'.
Parameter |
|
---|---|
e |
Event Mouse event or touch event. Value must not be null. |
- Returns
-
string
The touch identifier from the first changed touch, if defined. Otherwise 'mouse'.
isMouseOrTouchEvent
isMouseOrTouchEvent(e) returns boolean
Check whether a given event is a mouse or touch event.
Parameter |
|
---|---|
e |
Event An event. Value must not be null. |
- Returns
-
boolean
True if it is a mouse or touch event; false otherwise.
isTouchEvent
isTouchEvent(e) returns boolean
Check whether a given event is a touch event or a pointer event.
Parameter |
|
---|---|
e |
Event An event. Value must not be null. |
- Returns
-
boolean
True if it is a touch event; false otherwise.
setClientFromTouch
setClientFromTouch(e)
Set an event's clientX and clientY from its first changed touch. Use this to make a touch event work in a mouse event handler.
Parameter |
|
---|---|
e |
Event A touch event. Value must not be null. |
shouldHandleEvent
shouldHandleEvent(e) returns boolean
Decide whether Blockly should handle or ignore this event. Mouse and touch events require special checks because we only want to deal with one touch stream at a time. All other events should always be handled.
Parameter |
|
---|---|
e |
Event The event to check. Value must not be null. |
- Returns
-
boolean
True if this event should be passed through to the registered handler; false if it should be blocked.
splitEventByTouches
splitEventByTouches(e) returns Array of non-null Event
Split an event into an array of events, one per changed touch or mouse point.
Parameter |
|
---|---|
e |
Event A mouse event or a touch event with one or more changed touches. Value must not be null. |
- Returns
-
non-null Array of non-null Event
An array of mouse or touch events. Each touch event will have exactly one changed touch.