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[]

    Example

    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

    Example

    // 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

    Example

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

    Parameters

    • item: any

      The item

    Returns boolean

    If item is in selection

    Example

    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

    Example

    // 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

    Example

    // 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

    Example

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