GLG Toolkit, JavaScript Library  Version 4.6
Touch Interaction

This group contains methods for handling touch interaction. More...

Detailed Description

This group contains methods for handling touch interaction.

These methods can be used inside the Trace callback to implement custom touch behavior.

By default, browsers dispatch emulated mouse and click events on a single touch event. An application can enable handling of touch events via SetTouchMode in order to implement custom touch behavior (such as scroll a chart by touching and dragging it), as shown in the examples_html5/realtime_chart/GlgRealTimeChart.js file in GLG installation directory.

GLG sliders and knob interaction handlers automatically activate the touch mode to handle dragging via the touch move events. The GlgSliderTouchDrag global configuration resource may be used to disable this feature if it interferes with the browser use of the touch events for scrolling and zooming the web page.

Functions

static void EnableMultiTouchDefaultAction (bool state)
 Enables or disables default browser actions on double touch when touch events are enabled. More...
 
static boolean GetTouchMode ()
 Queries the state of the GLG touch mode. More...
 
static void SetTouchMode ()
 Enables handling of touch events. More...
 

Function Documentation

◆ EnableMultiTouchDefaultAction()

static void EnableMultiTouchDefaultAction ( bool  state)
static

Enables or disables default browser actions on double touch when touch events are enabled.

If default browser actions on double touch are enabled (default), an application can use single touch for application activities, such as scrolling a real-time chart by touching and dragging, while letting the browser scroll or zoom the page when two fingers are used inside the GLG component. The double-touch events will be handled by the browser and will not be sent to the application's Trace callback.

Default browser actions on double touch can be disabled for applications that either provide custom handling of double touch events or want to disable the default scrolling and zooming actions in response to the touch events inside the GLG component. Default browser actions on double touch are disabled by passing false as the method's parameter, in which case all touch events will be passed to the application's Trace callback regardless of the number of simultaneous touches.

Parameters
statetrue to enable default browser actions on double touch or false to disable them.

◆ GetTouchMode()

static boolean GetTouchMode ( )
static

Queries the state of the GLG touch mode.

Returns
true if the touch mode is currently enabled by SetTouchMode.

◆ SetTouchMode()

static void SetTouchMode ( )
static

Enables handling of touch events.

The method may be invoked on the TOUCH_START event inside the Trace callback to enable handing of the consequent TOUCH_MOVED, TOUCH_END and TOUCH_CANCEL events.

If the touch mode is enabled, the default browser handling of touch events will be disabled, and the application will receive these events in the Trace callback to implement application-defined touch actions. For example, an application could use touch move events to drag objects or scroll the chart.

If the touch mode is not enabled, the browser will use touch events for scrolling or zooming the web page, and the application will not receive any touch events after the initial TOUCH_START event. The MOUSE_MOVED, MOUSE_PRESSED and MOUSE_RELEASED events will be received after the browser finished handling touch events.

The enabled state of touch mode is active only for the duration of one touch event sequence, and is reset when the touch ends or is canceled.

The examples_html5/realtime_chart/GlgRealTimeChart.js file in GLG installation directory provides an example handling touch events to scroll a chart by touching and dragging it.

GLG sliders and knob interaction handlers automatically activate the touch mode to handle dragging via the touch move events. The GlgSliderTouchDrag global configuration resource may be used to disable this feature if it interferes with the browser use of the touch events for scrolling and zooming the web page.