#cp.ui.ScrollArea

A ScrollArea represents an AXScrollArea. They primarily function as a "portal" to view a larger area of the contained axuielement within (accessed via the AXContents attribute), and also provide access to the vertical and horizontal scroll bars (accessed via the verticalScrollBar and horizontalScrollBar properties).

The class that wraps the AXContents attribute can be provided via the contentsInit parameter in the constructor. If not provided it defaults to Element.

The ScrollArea also delegates to the contents property, so you can access any properties of the contained Element directly.

For example, if you have a ScrollArea with a contents of a TextField, you can normally access the text value via the TextField.value property. However, if you want to access the text value via the ScrollArea itself, you can do so via the ScrollArea.value property, like so:

local scrollArea = ScrollArea(parent, ui, TextArea) -- via `contents`: local value = scrollArea.contents:value() --- via delegation: local value = scrollArea:value()

It also has a Builder that supports customising an Element Builder to create a ScrollArea with a specified contents Element type. For example, another way to define our ScrollArea that contains a TextField is:

local scrollAreaWithTextField = ScrollArea:containing(TextField) local scrollArea = scrollAreaWithTextField(parent, ui)

The main advantage of this style is that you can pass the Builder in to other Element types that require an "Element init" that will only be provided a parent and UI finder.

This is a subclass of Element.


#Submodules


#API Overview

Functions - API calls offered directly by the extension

Constructors - API calls which return an object, typically one that offers API methods

Fields - Variables which can only be accessed from an object returned by a constructor

Methods - API calls which can only be made on an object returned by a constructor


#API Documentation

#Functions

Signaturecp.ui.ScrollArea:containing(elementInit) -> cp.ui.ScrollArea.Builder
TypeFunction
DescriptionA static method that returns a new ScrollArea.Builder.
Parameters
  • elementInit - An Element initializer.
Returns
  • A new ScrollArea.Builder instance.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 71

Signaturecp.ui.ScrollArea.matches(element) -> boolean
TypeFunction
DescriptionChecks to see if an element matches what we think it should be.
Parameters
  • element - An axuielementObject to check.
Returns
  • true if matches otherwise false
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 85

#Constructors

Signaturecp.ui.ScrollArea(parent, uiFinder[, contentsInit]) -> cp.ui.ScrollArea
TypeConstructor
DescriptionCreates a new ScrollArea.
Parameters
  • parent - The parent object.
  • uiFinder - A function or cp.prop which will return the hs.axuielement when available.
  • contentsInit - An optional function to initialise the contentsUI. Uses cp.ui.Element by default.
Returns
  • The new ScrollArea.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 96

#Fields

Signaturecp.ui.ScrollArea.contents <cp.ui.Element>
TypeField
DescriptionReturns the Element representing the ScrollArea Contents.
NotesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 119

Signaturecp.ui.ScrollArea.contentsUI <cp.prop: hs.axuielement; read-only; live?>
TypeField
DescriptionReturns the axuielement representing the Scroll Area Contents, or nil if not available.
NotesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 112

Signaturecp.ui.ScrollArea.horizontalScrollBar <cp.ui.ScrollBar>
TypeField
DescriptionThe horizontal ScrollBar.
NotesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 133

Signaturecp.ui.ScrollArea.selectedChildrenUI <cp.prop: hs.axuielement; read-only; live?>
TypeField
DescriptionReturns the axuielement representing the Scroll Area Selected Children, or nil if not available.
NotesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 140

Signaturecp.ui.ScrollArea.verticalScrollBar <cp.ui.ScrollBar>
TypeField
DescriptionThe vertical ScrollBar.
NotesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 126

Signaturecp.ui.ScrollArea.viewFrame <cp.prop:table; read-only>
TypeField
DescriptionA cp.prop reporting the Scroll Area frame as a table containing {x, y, w, h}.
NotesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 171

#Methods

Signaturecp.ui.ScrollArea:childrenUI(filterFn) -> hs.axuielement | nil
TypeMethod
DescriptionReturns the list of axuielements representing the Scroll Area Contents, sorted top-down, or nil if not available.
Parameters
  • filterFn - The function which checks if the child matches the requirements.
Returns
  • The axuielement or nil.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 153

Signaturecp.ui.ScrollArea:deselectAll() -> self
TypeMethod
DescriptionDeselect all children in a scroll area.
Parameters
  • None
Returns
  • Self
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 305

Signaturecp.ui.ScrollArea:loadLayout(layout) -> none
TypeMethod
DescriptionLoads a Scroll Area layout.
Parameters
  • layout - A table containing the ScrollArea layout settings, typically created using saveLayout.
Returns
  • None
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 393

Signaturecp.ui.ScrollArea:saveLayout() -> table
TypeMethod
DescriptionSaves the current Scroll Area layout to a table.
Parameters
  • None
Returns
  • A table containing the current Scroll Area Layout.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 374

Signaturecp.ui.ScrollArea:selectAll(childrenUI) -> self
TypeMethod
DescriptionSelect all children in a scroll area.
Parameters
  • childrenUI - A table of hs.axuielement objects.
Returns
  • Self
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 286

Signaturecp.ui.ScrollArea:selectChild(childUI) -> self
TypeMethod
DescriptionSelect a specific child within a Scroll Area.
Parameters
  • childUI - The hs.axuielement object of the child you want to select.
Returns
  • Self
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 250

Signaturecp.ui.ScrollArea:selectChildAt(index) -> self
TypeMethod
DescriptionSelect a child element in a Scroll Area given a specific index.
Parameters
  • index - The index of the child you want to select.
Returns
  • Self
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 269

Signaturecp.ui.ScrollArea:shiftHorizontalBy(amount) -> number
TypeMethod
DescriptionAttempts to shift the horizontal scroll bar by the specified amount.
Parameters
  • amount - The amount to shift
Returns
  • The actual value of the horizontal scroll bar.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 322

Signaturecp.ui.ScrollArea:shiftHorizontalTo(value) -> number
TypeMethod
DescriptionAttempts to shift the horizontal scroll bar to the specified value.
Parameters
  • value - The new value (typically between 0 and 1).
Returns
  • The actual value of the horizontal scroll bar.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 335

Signaturecp.ui.ScrollArea:shiftVerticalBy(amount) -> number
TypeMethod
DescriptionAttempts to shift the vertical scroll bar by the specified amount.
Parameters
  • amount - The amount to shift
Returns
  • The actual value of the vertical scroll bar.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 348

Signaturecp.ui.ScrollArea:shiftVerticalTo(value) -> number
TypeMethod
DescriptionAttempts to shift the vertical scroll bar to the specified value.
Parameters
  • value - The new value (typically between 0 and 1).
Returns
  • The actual value of the vertical scroll bar.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 361

Signaturecp.ui.ScrollArea:showChild(childUI) -> self
TypeMethod
DescriptionShow's a child element in a Scroll Area.
Parameters
  • childUI - The hs.axuielement object of the child you want to show.
Returns
  • Self
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 195

Signaturecp.ui.ScrollArea:showChildAt(index) -> self
TypeMethod
DescriptionShow's a child element in a Scroll Area given a specific index.
Parameters
  • index - The index of the child you want to show.
Returns
  • Self
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ScrollArea.lua line 233