#cp.ui.ElementCache

Provides caching for Element subclasses that want to cache children.


#API Overview

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

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


#API Documentation

#Constructors

Signaturecp.ui.ElementCache(parent[, createFn])
TypeConstructor
DescriptionCreates and returns a new ElementCache, with the specified parent and function which will create new elements on demand. The createFn has the signature of function(parent, ui) -> cp.ui.Element, and should take the parent provided here and the axuielement and return a new Element subclass.
Parameters
  • parent - the parent Element that contains the cached items.
  • createFn - a function that will create new Element subclasses based on cached axuielement values.
Returns
  • The new ElementCache.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ElementCache.lua line 12

#Methods

Signaturecp.ui.ElementCache:cachedElement(ui) -> cp.ui.Element or nil
TypeMethod
DescriptionReturns the cached Element, if it is present.
Parameters
  • ui - The axuielement it is linked to. If not provided, it will be fetched by calling Element:UI().
Returns
  • cp.ui.Element or nil
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ElementCache.lua line 61

Signaturecp.ui.ElementCache:cacheElement(element[, ui]) -> none
TypeMethod
DescriptionCaches the provided Element.
Parameters
  • element - The Element
  • ui - The axuielement it is linked to. If not provided, it will be fetched by calling Element:UI().
Returns
  • None
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ElementCache.lua line 81

Signaturecp.ui.ElementCache:clean()
TypeMethod
DescriptionClears the cache of any invalid (aka dead) items.
Parameters
  • None
Returns
  • None
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ElementCache.lua line 28

Signaturecp.ui.ElementCache:fetchElement(ui) -> cp.ui.Element or nil
TypeMethod
DescriptionRetrieves the matching Element instance from the cache. If none exists and the createFn was provided in the constructor, it will be used to create a new one, which is automatically cached for future reference.
Parameters
  • ui - The axuielement being fetched for.
Returns
  • cp.ui.Element or nil
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ElementCache.lua line 99

Signaturecp.ui.ElementCache:fetchElements(uis) -> table of cp.ui.Elements or nil
TypeMethod
DescriptionFetches a list of Element instances linked to the provided axuielement list.
Parameters
  • uis - A table of axuielement values.
Returns
Notes
  • If any of the provided axuielement values are either not from the parent, or no longer valid, a nil value will be stored in the matching index. Note that in that case, this will break useage of ipairs due to leaving holes in the list.
ExamplesNone
Sourcesrc/extensions/cp/ui/ElementCache.lua line 126

Signaturecp.ui.ElementCache:reset() -> none
TypeMethod
DescriptionRemoves all cached items from the cache.
Parameters
  • None
Returns
  • None
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/ElementCache.lua line 48