Options
All
  • Public
  • Public/Protected
  • All
Menu

A manager of Undoables.

You can add Undoables to this manager, which will maintain a stack of undoables that you can undo or redo.

You can wire a keyboard shortcut, like CTRL+Z to undo, as follows:

You usually create undoables in response to an event from the API, and then add them to an UndoManager. You can find a list of common events in Undoable.

This example shows how to create Undoables in LuciadRIA:

You can find the full source, and more examples, in samples/common/util/SampleUndoSupport.ts.

See the Adding undo/redo support to your application guide for more information on how to work with undo/redo in LuciadRIA.

see

Undoable

since

2022.1

Hierarchy

  • UndoManager

Overview

Constructors

Events

Accessors

Methods

Constructors

constructor

  • Creates a new UndoManager instance

    Parameters

    • Optional limit: number

      The maximum amount of Undoable this manager should track on its undoStack. Defaults to 10.

    Returns UndoManager

Events

on

  • (event: "UndoStackChanged", callback: () => void): Handle
  • (event: "RedoStackChanged", callback: () => void): Handle
  • (event: "LimitChanged", callback: () => void): Handle
  • An event that fires whenever the undoStack of this UndoManager changes.

    Parameters

    • event: "UndoStackChanged"
    • callback: () => void
        • (): void
        • Returns void

    Returns Handle

  • An event that fires whenever the redoStack of this UndoManager changes.

    Parameters

    • event: "RedoStackChanged"
    • callback: () => void
        • (): void
        • Returns void

    Returns Handle

  • An event that fires whenever the limit of this UndoManager changes.

    Parameters

    • event: "LimitChanged"
    • callback: () => void
        • (): void
        • Returns void

    Returns Handle

Accessors

limit

  • get limit(): number
  • set limit(limit: number): void
  • Returns the current limit of the UndoManager

    This limits the size of the undoStack. If the size of the undoStack exceeds the limit, the oldest Undoables on the stack are removed.

    If the new limit is lower than the old limit, the oldest items on the undoStack will be discarded, without applying them.

    Returns number

  • Sets the limit of the UndoManager.

    This limits the size of the undoStack. If the size of the undoStack exceeds the limit, the oldest Undoables on the stack are removed.

    If the new limit is lower than the old limit, the oldest items on the undoStack will be discarded, without applying them.

    Parameters

    • limit: number

      The new limit. Must be strictly positive.

    Returns any

redoStack

  • Returns a copy of the redo stack. The upcoming undoable is the last element in the array.

    You can use this stack to show one or more upcoming undoables, for example in a drop-down box of a redo button.

    Returns Undoable[]

undoStack

  • Returns a copy of the undo stack. The upcoming undoable is the last element in the array.

    You can use this stack to show one or more upcoming undoables, for example in a drop-down box of an undo button.

    Returns Undoable[]

Methods

canRedo

  • (): boolean
  • Indicates if this UndoManager can redo.

    An UndoManager can redo when there is at least 1 Undoable on the redoStack.

    Returns boolean

canUndo

  • (): boolean
  • Indicates if this UndoManager can undo.

    An UndoManager can undo when there is at least 1 Undoable on the undoStack.

    Returns boolean

push

redo

  • (): void

reset

  • (): void

undo

  • (): void

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method