fold

Type Event
Revision Release 2026.3728
Keywords fold, foldable, hinge, posture
See also display.getReservedRegions()
system.getInfo()
system.hasEventSource()
resize

Overview

A fold event occurs when a foldable device’s hinge changes state, for example when it is opened flat, half opened into a “tabletop” or “book” posture, or closed.

Fold event listeners can only be set up via the Runtime object. Soon after you add a listener, an event reports the device’s current state.

Folding or unfolding a device usually changes the size of the app’s view too. Use the resize event to re-layout your content, and use the fold event to react to the posture itself, such as moving controls to the lower half when the device is half open.

Platform Support

Use system.hasEventSource( "fold" ) (reference) to check whether the current device and build can send fold events.

Properties

event.angle

event.bounds

event.name

event.orientation

event.state

Example

local function onFold( event )
    print( "Fold state: " .. event.state )

    if ( event.state == "halfOpen" and event.orientation == "horizontal" and event.bounds ) then
        -- Tabletop posture: keep content above the hinge, controls below it
        local hingeY = event.bounds.y + event.bounds.height
        print( "Hinge ends at y = " .. hingeY )
    end
end

if system.hasEventSource( "fold" ) then
    Runtime:addEventListener( "fold", onFold )
end