documentationfor yFiles for HTML 2.6

Touch handling

GraphEditorInputMode and GraphViewerInputMode allow convenient handling of tap gestures on items. Both single and double taps are reported in a similar manner as mouse clicks. Note that a tap or double tap will raise the same events as a mouse click or double click. Also, property clickableItems specifies the graph item types for which a tap is reported as well. The dispatched events are listed in the table below:

Related events
Event Occurs when …​
ItemClicked…​ a tap on on a clickable item occurred.
ItemDoubleClicked…​ a double tap on a clickable item occurred.
CanvasClicked…​ a tap is performed at a location where no clickable item can be found. Note that this may be on another item if that item is not clickable. The default action in this case is to create a new node (cf. Customizing Creating Nodes). Handling this event will prevent that.

In most cases handling click events only will suffice. If you need complete control over what happens on clicks within GraphEditorInputMode or GraphViewerInputMode you can override the tap method which handles all the default actions, such as raising click events, propagating them to items that are at the tapped location and also handling default actions, such as selection and focus.

Defining the items for which taps are reported as well as defining the hit test order can be achieved using the same properties as for mouse clicks. Please refer to the according section.

The actual tap handling is delegated to GraphEditorInputMode’s and GraphViewerInputMode’s child input mode TapInputMode. Both listen for ClickInputMode’s Tapped and DoubleTapped events to handle taps and double taps.

Related events
Event Occurs when …​
Tapped…​ a tap has been detected.
DoubleTapped…​ a double tap has been detected.

You may want to listen for these events, if GraphEditorInputMode’s or GraphViewerInputMode’s item click events are not applicable for your use case.

TapInputMode provides a number of properties to further customize tap handling:

validTapHitTestable
Allows to restrict the area where taps should be recognized. By default the area is unrestricted.
swallowFocusTap
Whether taps should be discarded if they occur within 100ms after the canvas got the focus. By default this is disabled.