Selection API. Allows selecting Entities, Assets etc.

Hierarchy

  • Events
    • Selection

Internal

Other

  • get items(): any[]
  • Gets the selected items. This creates a new array every time it is called.

    Returns any[]

    editor.selection.items.add(editor.entities.root);
    const selectedEntities = editor.selection.items;
  • Add item to selection

    Parameters

    • item: any

      The item

    • options: { history: boolean } = {}

      Options

      • history: boolean

        Whether to record a history action. Defaults to true.

    Returns void

    // add root entity to selection
    editor.selection.add(editor.entities.root);
  • Clears selection

    Parameters

    • options: { history: boolean } = {}

      Options

      • history: boolean

        Whether to record a history action. Defaults to true.

    Returns void

    editor.selection.clear();
    
  • Checks if item is in selection

    Parameters

    • item: any

      The item

    Returns boolean

    If item is in selection

    const isRootSelected = editor.selection.has(editor.entities.root);
    
  • Remove item from selection

    Parameters

    • item: any

      The item

    • options: { history: boolean } = {}

      Options

      • history: boolean

        Whether to record a history action. Defaults to true.

    Returns void

    // remove root entity from selection
    editor.selection.remove(editor.entities.root);
  • Sets current selection

    Parameters

    • items: any[]

      The items to select

    • options: { history: boolean } = {}

      Options

      • history: boolean

        Whether to record a history action. Defaults to true.

    Returns void

    // select root entity
    editor.selection.set([editor.entities.root]);
  • Toggle item selection

    Parameters

    • item: any

      The item

    • options: { history: boolean } = {}

      Options

      • history: boolean

        Whether to record a history action. Defaults to true.

    Returns void

    // toggle root entity selection
    editor.selection.toggle(editor.entities.root);