Options
All
  • Public
  • Public/Protected
  • All
Menu
example
var undoManager = new mxUndoManager();
var listener(sender, evt)
{
  undoManager.undoableEditHappened(evt.getProperty('edit'));
};
graph.getModel().addListener(mxEvent.UNDO, listener);
graph.getView().addListener(mxEvent.UNDO, listener);

The code creates a function that informs the undoManager of an undoable edit and binds it to the undo event of mxGraphModel and mxGraphView using mxEventSource.addListener.

Event: mxEvent.CLEAR

Fires after clear was invoked. This event has no properties.

Event: mxEvent.UNDO

Fires afer a significant edit was undone in undo. The edit property contains the mxUndoableEdit that was undone.

Event: mxEvent.REDO

Fires afer a significant edit was redone in redo. The edit property contains the mxUndoableEdit that was redone.

Event: mxEvent.ADD

Fires after an undoable edit was added to the history. The edit property contains the mxUndoableEdit that was added.

Hierarchy

Index

Constructors

constructor

Properties

eventListeners

eventListeners: any[]

Variable: eventListeners

Holds the event names and associated listeners in an array. The array contains the event name followed by the respective listener for each registered listener.

eventSource

eventSource: any

Variable: eventSource

Optional source for events. Default is null.

eventsEnabled

eventsEnabled: boolean

Variable: eventsEnabled

Specifies if events can be fired. Default is true.

history

history: mxUndoableEdit[]

Array that contains the steps of the command history.

indexOfNextAdd

indexOfNextAdd: number

Index of the element to be added next.

size

size: number

Maximum command history size. 0 means unlimited history. Default is 100.

default

100

Methods

addListener

  • addListener(name: string, funct: (...args: any[]) => any): void
  • Function: addListener

    Binds the specified function to the given event name. If no event name is given, then the listener is registered for all events.

    The parameters of the listener are the sender and an .

    Parameters

    • name: string
    • funct: (...args: any[]) => any
        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    Returns void

canRedo

  • canRedo(): boolean

canUndo

  • canUndo(): boolean

clear

  • clear(): void

fireEvent

  • Function: fireEvent

    Dispatches the given event to the listeners which are registered for the event. The sender argument is optional. The current execution scope ("this") is used for the listener invocation (see <mxUtils.bind>).

    Example:

    (code) fireEvent(new mxEventObject("eventName", key1, val1, .., keyN, valN)) (end)

    Parameters:

    evt - that represents the event. sender - Optional sender to be passed to the listener. Default value is the return value of .

    Parameters

    Returns void

getEventSource

  • getEventSource(): any

isEmpty

  • isEmpty(): boolean

isEventsEnabled

  • isEventsEnabled(): boolean

redo

  • redo(): void

removeListener

  • removeListener(funct: (...args: any[]) => any): void
  • Function: removeListener

    Removes all occurrences of the given listener from .

    Parameters

    • funct: (...args: any[]) => any
        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    Returns void

setEventSource

  • setEventSource(value: any): void

setEventsEnabled

  • setEventsEnabled(value: boolean): void

trim

  • trim(): void
  • Removes all pending steps after from the history, invoking die on each edit. This is called from .

    Returns void

undo

  • undo(): void

undoableEditHappened

Generated using TypeDoc