Home Reference Source
import {Selection} from './api/Selection.js'
public class | source

Selection

Extends:

WrappedObject → Selection

Represents the layers that the user has selected.

Static Method Summary

Static Public Methods
public static

tests(): dictionary

Return a list of tests to run for this class.

Constructor Summary

Public Constructor
public

constructor(page: Page)

Make a new Selection object.

Member Summary

Public Members
public get

Does the selection contain any layers?

public get

Return the number of selected layers.

public get

nativeLayers: array: *

Return the native Sketch layers in the selection.

Method Summary

Public Methods
public

clear()

Clear the selection.

public

iterate(block: function(layer: Layer))

Perform an action once for each layer in the selection.

public

iterateThenClear(block: function(layer: Layer))

Perform an action once for each layer in the selection, then clear it.

public

iterateWithFilter(filter: function(layer: Layer), block: function(layer: Layer))

Perform an action once for each layer in the selection that passes a filter.

public

iterateWithFilterThenClear(filter: function(layer: Layer), block: function(layer: Layer))

Perform an action once for each layer in the selection that passes a filter, then clear the selection.

Inherited Summary

From class WrappedObject
public static

tests(): dictionary

Return a list of tests to run for this class.

public get

id: string: *

Returns the object ID of the wrapped Sketch model object.

public get

Returns the wrapped Sketch object.

Static Public Methods

public static tests(): dictionary source

Return a list of tests to run for this class.

Return:

dictionary

A dictionary containing the tests to run. Each key is the name of a test, each value is a function which takes a Tester instance.

Public Constructors

public constructor(page: Page) source

Make a new Selection object.

Params:

NameTypeAttributeDescription
page Page

The page that the selection relates to.

Public Members

public get isEmpty: boolean: * source

Does the selection contain any layers?

Return:

boolean

true if the selection is empty.

public get length: number: * source

Return the number of selected layers.

Return:

number

The number of layers that are selected.

public get nativeLayers: array: * source

Return the native Sketch layers in the selection.

Return:

array

The selected layers.

Public Methods

public clear() source

Clear the selection.

public iterate(block: function(layer: Layer)) source

Perform an action once for each layer in the selection.

Params:

NameTypeAttributeDescription
block function(layer: Layer)

The function to execute for each layer.

public iterateThenClear(block: function(layer: Layer)) source

Perform an action once for each layer in the selection, then clear it.

Params:

NameTypeAttributeDescription
block function(layer: Layer)

The function to execute for each layer.

public iterateWithFilter(filter: function(layer: Layer), block: function(layer: Layer)) source

Perform an action once for each layer in the selection that passes a filter.

Params:

NameTypeAttributeDescription
filter function(layer: Layer)

Filter function called on each layer first to check whether it should be iterated.

block function(layer: Layer)

The function to execute for each layer.

public iterateWithFilterThenClear(filter: function(layer: Layer), block: function(layer: Layer)) source

Perform an action once for each layer in the selection that passes a filter, then clear the selection.

Params:

NameTypeAttributeDescription
filter function(layer: Layer)

Filter function called on each layer first to check whether it should be iterated.

block function(layer: Layer)

The function to execute for each layer.

See something wrong or incomplete? Improve this page.