# GSLayer Selection

*API Collection*

Access and modify the elements selected in a layer.

## Overview

A selection is an ordered set of selectable elements. Selecting nodes does not select their path, and a selection can contain different kinds of elements.

Most selection mutation methods notify observers but do not register undo. Use the methods that include `Undo` when the selection change must be undoable.

## Topics

### Selection

- [`GSLayer.selection`](/Core/GlyphsCore/GSLayer/selection) — The selected elements in selection order.
- [`GSLayer countOfSelection`](/Core/GlyphsCore/GSLayer/countOfSelection) — The number of selected elements.
- [`GSLayer setSelectionUndo:`](/Core/GlyphsCore/GSLayer/setSelectionUndo:) — Replaces the selection and registers the previous selection for undo.
- [`GSLayer addSelection:`](/Core/GlyphsCore/GSLayer/addSelection:) — Adds an element to the selection if it is not already selected.
- [`GSLayer addObjectsFromArrayToSelection:`](/Core/GlyphsCore/GSLayer/addObjectsFromArrayToSelection:) — Adds elements to the selection, preserving their order.
- [`GSLayer replaceSelection:`](/Core/GlyphsCore/GSLayer/replaceSelection:) — Replaces the selection without registering undo.
- [`GSLayer removeObjectFromSelectionAtIndex:`](/Core/GlyphsCore/GSLayer/removeObjectFromSelectionAtIndex:) — Removes the selected element at an index.
- [`GSLayer removeObjectFromSelection:`](/Core/GlyphsCore/GSLayer/removeObjectFromSelection:) — Removes an element from the selection.
- [`GSLayer removeObjectsFromSelection:`](/Core/GlyphsCore/GSLayer/removeObjectsFromSelection:) — Removes elements from the selection.
- [`GSLayer clearSelection`](/Core/GlyphsCore/GSLayer/clearSelection) — Clears the selection without registering undo.
- [`GSLayer clearSelectionUndo`](/Core/GlyphsCore/GSLayer/clearSelectionUndo) — Clears the selection and registers the previous selection for undo.
- [`GSLayer selectionContainsObject:`](/Core/GlyphsCore/GSLayer/selectionContainsObject:) — Whether an element is selected.

### Selection Serialization

- [`GSLayer selectedObjects`](/Core/GlyphsCore/GSLayer/selectedObjects) — Content representing the selected elements for serialization and paste.
- [`GSLayer selectedElementsMappings`](/Core/GlyphsCore/GSLayer/selectedElementsMappings) — Structural mappings for the selected elements.
- [`GSLayer removeMappedElements:`](/Core/GlyphsCore/GSLayer/removeMappedElements:) — Removes elements described by structural mappings.
- [`GSLayer removeElement:`](/Core/GlyphsCore/GSLayer/removeElement:) — Removes a selectable element from the layer.
- [`GSLayer removeNodesCutPath:`](/Core/GlyphsCore/GSLayer/removeNodesCutPath:) — Removes mapped nodes while preserving the unselected path portions.
- [`GSLayer pasteDict:format:selectedNodes:error:`](/Core/GlyphsCore/GSLayer/pasteDict:format:selectedNodes:error:) — Adds content from a serialized selection dictionary.
- [`GSLayer selectedPaths:notSelected:`](/Core/GlyphsCore/GSLayer/selectedPaths:notSelected:) — Separates paths by whether they contain selected nodes.

## See Also

- [GSLayer Kind](/Core/GlyphsCore/GSLayer-Kind) — The different roles that a layer can serve.
- [GSLayer Shapes](/Core/GlyphsCore/GSLayer-Shapes) — The paths and components that form the outline of a layer.
- [GSLayer Bounds](/Core/GlyphsCore/GSLayer-Bounds) — Bounding rectangles of outlines, selections, and metrics.
- [GSLayer Metrics](/Core/GlyphsCore/GSLayer-Metrics) — Side bearings, baseline offsets, layer box, and metrics keys.
- [GSLayer Grid](/Core/GlyphsCore/GSLayer-Grid) — Setting for rounding coordinates on a layer.
- [GSLayer Background](/Core/GlyphsCore/GSLayer-Background) — Background content and reference images associated with a layer.
- [GSLayer Anchors](/Core/GlyphsCore/GSLayer-Anchors) — Named attachment points on a layer.
- [GSLayer Hints](/Core/GlyphsCore/GSLayer-Hints) — Manual and generated hint data on a layer.
- [GSLayer Guides](/Core/GlyphsCore/GSLayer-Guides) — Layer-local guides used while editing outlines.
- [GSLayer Kerning](/Core/GlyphsCore/GSLayer-Kerning) — Spacing adjustment between specific layers.
- [GSLayer Annotations](/Core/GlyphsCore/GSLayer-Annotations) — Layer-local notes displayed with a glyph.
- [GSLayer Interpolation](/Core/GlyphsCore/GSLayer-Interpolation) — Axis coordinates and rules that place layers in a design space.
- [GSLayer Color](/Core/GlyphsCore/GSLayer-Color) — Colors used to draw a layer.
- [GSLayer Attributes](/Core/GlyphsCore/GSLayer-Attributes) — Additional values stored for a layer.
- [GSLayer Inspection](/Core/GlyphsCore/GSLayer-Inspection) — Intersections between layer outlines and line segments.

