object:setIsLocked()

Type Function
Library widget.*
Revision Release 2024.3703
Keywords widget, scroll view, ScrollViewWidget, setIsLocked
See also widget.newScrollView()
ScrollViewWidget

Overview

Sets a ScrollViewWidget to either locked (does not scroll) or unlocked (default behavior). Optionally, you can lock or unlock the scroll view on a specific directional axis.

Syntax

object:setIsLocked( isLocked [, axis] )
isLocked (required)

Boolean. Set to true to lock the scroll view; false to unlock the scroll view.

axis (optional)

String. Directional axis upon which to lock or unlock the scroll view, either "horizontal" or "vertical".

Examples

Lock on Delay
local scrollView = widget.newScrollView {
    width = 400,
    height = 400,
    left = 0,
    top = 0,
    scrollWidth = 800,
    scrollHeight =  1200,
    hideBackground = false
}

local function lockScrollView()
    scrollView:setIsLocked( true )
end

-- Lock the scroll view after 2 seconds
timer.performWithDelay( 2000, lockScrollView )
Lock Specific Axis
local scrollView = widget.newScrollView {
    width = 400,
    height = 400,
    left = 0,
    top = 0,
    scrollWidth = 800,
    scrollHeight =  1200,
    hideBackground = false
}

-- Lock the scroll view only on the horizontal axis
scrollView:setIsLocked( true, "horizontal" )