system.activate()

Type Function
Library system.*
Return value none
Revision Release 2024.3703
Keywords multitouch
See also system.deactivate()

Overview

Activates a system-level feature such as "multitouch". Similarly, you can use system.deactivate() to disable a feature.

Multitouch is disabled by default, so you must always initially activate it via this method.

Syntax

system.activate( feature )
feature (required)

String. The system feature to be activated. Currently, the only supported values include:

Example

-- The following sample activates multitouch and creates a touch listener for a graphic
-- This displays the location, phase, and touch ID of each touch event

system.activate( "multitouch" )
 
local bg = display.newRect( 0, 0, 320, 480 )
local output = native.newTextBox( 0, 20, 320, 240 )
output.size = 12
 
local function showTouch( event )
    -- Display the event info on the screen
    output.text = output.text .. "\nPhase: " .. event.phase
    output.text = output.text .. "\n(" .. event.x .. "," .. event.y .. ")"
    output.text = output.text .. "\nId: " .. tostring( event.id )
end
 
bg:addEventListener( "touch", showTouch )