Options
All
  • Public
  • Public/Protected
  • All
Menu

Event handler that highlights cells

example
new mxCellTracker(graph, '#00FF00');

For detecting dragEnter, dragOver and dragLeave on cells, the following code can be used:

example
graph.addMouseListener(
{
  cell: null,
  mouseDown: function(sender, me) { },
  mouseMove: function(sender, me)
  {
    var tmp = me.getCell();

    if (tmp != this.cell)
    {
      if (this.cell != null)
      {
        this.dragLeave(me.getEvent(), this.cell);
      }

      this.cell = tmp;

      if (this.cell != null)
      {
        this.dragEnter(me.getEvent(), this.cell);
      }
    }

    if (this.cell != null)
    {
      this.dragOver(me.getEvent(), this.cell);
    }
  },
  mouseUp: function(sender, me) { },
  dragEnter: function(evt, cell)
  {
    mxLog.debug('dragEnter', cell.value);
  },
  dragOver: function(evt, cell)
  {
    mxLog.debug('dragOver', cell.value);
  },
  dragLeave: function(evt, cell)
  {
    mxLog.debug('dragLeave', cell.value);
  }
});

Hierarchy

Index

Constructors

constructor

Properties

currentColor

currentColor: string

Variable: currentColor

Holds the current marker color.

enabled

enabled: boolean

Variable: enabled

Specifies if the marker is enabled. Default is true.

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.

graph

graph: mxGraph

Variable: graph

Reference to the enclosing .

hotspot

hotspot: number

Variable: hotspot

Specifies the portion of the width and height that should trigger a highlight. The area around the center of the cell to be marked is used as the hotspot. Possible values are between 0 and 1. Default is mxConstants.DEFAULT_HOTSPOT.

hotspotEnabled

hotspotEnabled: boolean

Variable: hotspotEnabled

Specifies if the hotspot is enabled. Default is false.

invalidColor

invalidColor: string

Variable: invalidColor

Holds the invalid marker color.

markedState

markedState: mxCellState

Variable: markedState

Holds the marked .

validColor

validColor: string

Variable: validColor

Holds the valid marker color.

validState

validState: mxCellState

Variable: validState

Holds the marked if it is valid.

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

destroy

  • destroy(): void
  • Function: destroy

    Destroys the object and all its resources and DOM nodes. This doesn't normally need to be called. It is called automatically when the window unloads.

    Returns 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

getCell

getEventSource

  • getEventSource(): any

getHotspot

  • getHotspot(): number

getMarkedState

getMarkerColor

  • getMarkerColor(evt: Event, state: mxCellState, isValid: boolean): string

getState

getStateToMark

getValidState

hasValidState

  • hasValidState(): boolean

intersects

isEnabled

  • isEnabled(): boolean

isEventsEnabled

  • isEventsEnabled(): boolean

isHotspotEnabled

  • isHotspotEnabled(): boolean

isValidState

mark

  • mark(): void

markCell

  • markCell(cell: mxCell, color: string): void

mouseDown

mouseMove

  • Handles the event by highlighting the cell under the mousepointer if it is over the hotspot region of the cell.

    Parameters

    Returns void

mouseUp

process

  • Function: process

    Processes the given event and cell and marks the state returned by with the color returned by . If the markerColor is not null, then the state is stored in . If returns true, then the state is stored in regardless of the marker color. The state is returned regardless of the marker color and valid state.

    Parameters

    Returns mxCellState

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

reset

  • reset(): void

setCurrentState

setEnabled

  • setEnabled(enabled: boolean): void
  • Function: setEnabled

    Enables or disables event handling. This implementation updates .

    Parameters:

    enabled - Boolean that specifies the new enabled state.

    Parameters

    • enabled: boolean

    Returns void

setEventSource

  • setEventSource(value: any): void

setEventsEnabled

  • setEventsEnabled(value: boolean): void

setHotspot

  • setHotspot(hotspot: number): void

setHotspotEnabled

  • setHotspotEnabled(enabled: boolean): void

unmark

  • unmark(): void

Generated using TypeDoc