documentationfor yFiles for HTML 3.0-EAP3

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 …​
item-clicked…​ a tap on on a clickable item occurred.
item-double-clicked…​ a double tap on a clickable item occurred.
canvas-clicked…​ 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 UNRESOLVED: M_yWorks.Controls.Input.GraphEditorInputMode.Click(yWorks.Graph.IModelItem,yWorks.Controls.Input.TapEventArgs) 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 ClickInputMode. Both listen for ClickInputMode’s UNRESOLVED: E_yWorks.Controls.Input.ClickInputMode.Tapped and UNRESOLVED: E_yWorks.Controls.Input.ClickInputMode.DoubleTapped events to handle taps.

Related events
Event Occurs when …​
UNRESOLVED: E_yWorks.Controls.Input.ClickInputMode.Tapped…​ a tap has been detected.
UNRESOLVED: E_yWorks.Controls.Input.ClickInputMode.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.

ClickInputMode provides a number of properties to further customize click handling:

Uses the values defined in ClickReportingPolicy to determine how to dispatch single tap events for double taps. By default, both the first and second tap are reported before the double tap itself is reported.
Allows to restrict the area where taps should be recognized. By default the area is unrestricted.
Whether taps should be discarded if they occur within 100ms after the canvas got the focus. By default this is disabled.