Skip to content

Latest commit

 

History

History
47 lines (30 loc) · 2.09 KB

setValidGestures.markdown

File metadata and controls

47 lines (30 loc) · 2.09 KB

simple_gesture.setValidGestures()

 
Type function
Library simple_gesture.*
Return value nil
Keywords simple, gesture, valid
See also Sample code, simple_gesture.getValidGestures(), simple_gesture.getSupportedGestures(), simple_gesture.gestureListener()

Overview

This function sets the valid gestures that can be returned by simple_gesture.gestureListener(). These must be either custom-defined gestures or supported, built-in gestures. A runtime error is raised if an unsupported gesture is specified.

Syntax

simple_gesture.setValidGestures( gestureArray )
simple_gesture.setValidGestures( gestureTable )
gestureArray (required)

Array. Array of string values that must be supported gesture types, as reported by simple_gesture.getSupportedGestures()

gestureTable (required)

Table. Used as an alternative to gestureArray for overriding the supported, built-in gestures. The keys are the names of the newly-defined gestures, and the values are Arrays, comprising the x and y coordinates of points on the unit circle.

Examples

local simple_gesture = require 'plugin.simple_gesture'

-- Set gestures from the supported, built-in gestures
simple_gesture.setValidGestures({"up", "down", "left", "right"})
local simple_gesture = require 'plugin.simple_gesture'
local math = require 'math'

local root2 = math.sqrt(2)

-- Define your own custom gestures
simple_gesture.setValidGestures({up_left={-root2, -root2}, down_left={-root2, root2}, right={1, 0}})