natiny.view.set_clip

Lua
natiny.view.set_clip(view [, clip])

Cuts off whatever sticks out of the view: its children are drawn only inside its rectangle, and the pointer finds only what is inside it.

Both halves, because they are one thing. A scissor put round the drawing by hand hides a row that has scrolled out of sight and leaves the pointer finding it anyway - the row is still laid out, so it is still hovered and still pressed. Clipping is the layout's answer to overflow, so the view owns it.

Off to begin with: nothing clips unless it is asked to, so a view may draw outside its parent - a menu, a tooltip, a handle on an edge - and still be pressed where it is seen.

Parameters

Name Type Default Description
view number View handle
clip boolean true false lets its children overflow again

Example

Lua
-- A list taller than the box it is read through: the box clips, and the
-- rows outside it are neither drawn nor pointed at.
local window = natiny.view.create(natiny.view.LAYOUT_FREE)
natiny.view.set_parent(window, panel)
natiny.view.set_clip(window)

local column = natiny.view.create(natiny.view.LAYOUT_VERTICAL)
natiny.view.set_parent(column, window)
natiny.view.set_offset(column, 0, -scroll)