Home Reference Source Test Repository
public class | source

MouseHandler

Mouse event handler. Calls the appropriate event handler for the current tool based on user actions.

Constructor Summary

Public Constructor
public

constructor(graph: Graph)

Constructs a MouseHandler instance.

Member Summary

Public Members
public
public
public
public

graph: *

public
public
public
public
public
public
public
public

Method Summary

Public Methods
public

contextAdd(arg: string, x: number, y: number)

Handle the context menu "add" action.

public

Get the graph component that is under the mouse when the context menu event was triggered.

public

Handle the context menu "delete" action.

public

contextSelect(event: Event, currentTool: Tool, x: number, y: number)

Handle context menu object selection.

public

Handle the context menu "toggle" action.

public

contextmenuEventListener(event: Event, x: number, y: number, contextMenu: ContextMenu)

Handles the contextmenu event.

public

downListener(event: Event, currentTool: Tool, x: number, y: number)

Handles the mousedown event for the left mouse button.

public

moveListener(event: Event, currentTool: Tool, x: number, y: number)

Handles the mousemove event for the left mouse button.

public

resetGraph(newGraph: Graph)

Update the graph reference.

public

Handles the mousedown event for the right mouse button.

public

Handles the mousemove event for the right mouse button.

public

Handles the mouseup event for the right mouse button.

public

upListener(event: Event, currentTool: Tool, x: number, y: number)

Handles the mouseup event for the left mouse button.

Public Constructors

public constructor(graph: Graph) source

Constructs a MouseHandler instance.

Params:

NameTypeAttributeDescription
graph Graph

The current Graph object.

Public Members

public clickStartX: * source

public clickStartY: * source

public draggedObject: * source

public graph: * source

public isDragging: boolean source

public isRightDragging: boolean source

public mousePressed: boolean source

public rightClickStartX: * source

public rightClickStartY: * source

public rightMousePressed: boolean source

public selectedObject: * source

public wasRightDragging: boolean source

Public Methods

public contextAdd(arg: string, x: number, y: number) source

Handle the context menu "add" action.

Params:

NameTypeAttributeDescription
arg string

Name of object to add.

x number

Mouse x-coordinate (in canvas coordinates).

y number

Mouse y-coordinate (in canvas coordinates).

public contextComponent(event: Event, x: number, y: number): Node | Edge | Label source

Get the graph component that is under the mouse when the context menu event was triggered.

Params:

NameTypeAttributeDescription
event Event

The Event object from the event listener.

x number

Mouse x-coordinate (in canvas coordinates).

y number

Mouse y-coordinate (in canvas coordinates).

Return:

Node | Edge | Label

The object that is under the mouse.

public contextDelete() source

Handle the context menu "delete" action.

public contextSelect(event: Event, currentTool: Tool, x: number, y: number) source

Handle context menu object selection.

Params:

NameTypeAttributeDescription
event Event

The Event object from the event listener.

currentTool Tool

The currently selected tool.

x number

Mouse x-coordinate (in canvas coordinates).

y number

Mouse y-coordinate (in canvas coordinates).

public contextToggle(arg: string) source

Handle the context menu "toggle" action.

Params:

NameTypeAttributeDescription
arg string

Name of the field to toggle.

public contextmenuEventListener(event: Event, x: number, y: number, contextMenu: ContextMenu) source

Handles the contextmenu event.

Params:

NameTypeAttributeDescription
event Event

The Event object from the event listener.

x number

Mouse x-coordinate (in canvas coordinates).

y number

Mouse y-coordinate (in canvas coordinates).

contextMenu ContextMenu

ContextMenu object.

public downListener(event: Event, currentTool: Tool, x: number, y: number) source

Handles the mousedown event for the left mouse button.

Params:

NameTypeAttributeDescription
event Event

The Event object from the event listener.

currentTool Tool

The currently selected tool.

x number

Mouse x-coordinate (in canvas coordinates).

y number

Mouse y-coordinate (in canvas coordinates).

public moveListener(event: Event, currentTool: Tool, x: number, y: number) source

Handles the mousemove event for the left mouse button.

Params:

NameTypeAttributeDescription
event Event

The Event object from the event listener.

currentTool Tool

The currently selected tool.

x number

Mouse x-coordinate (in canvas coordinates).

y number

Mouse y-coordinate (in canvas coordinates).

public resetGraph(newGraph: Graph) source

Update the graph reference.

Params:

NameTypeAttributeDescription
newGraph Graph

The new Graph object.

public rightDownListener(event: Event, x: number, y: number) source

Handles the mousedown event for the right mouse button.

Params:

NameTypeAttributeDescription
event Event

The Event object from the event listener.

x number

Mouse x-coordinate (in canvas coordinates).

y number

Mouse y-coordinate (in canvas coordinates).

public rightMoveListener(event: Event, x: number, y: number) source

Handles the mousemove event for the right mouse button.

Params:

NameTypeAttributeDescription
event Event

The Event object from the event listener.

x number

Mouse x-coordinate (in canvas coordinates).

y number

Mouse y-coordinate (in canvas coordinates).

public rightUpListener(event: Event, x: number, y: number) source

Handles the mouseup event for the right mouse button.

Params:

NameTypeAttributeDescription
event Event

The Event object from the event listener.

x number

Mouse x-coordinate (in canvas coordinates).

y number

Mouse y-coordinate (in canvas coordinates).

public upListener(event: Event, currentTool: Tool, x: number, y: number) source

Handles the mouseup event for the left mouse button.

Params:

NameTypeAttributeDescription
event Event

The Event object from the event listener.

currentTool Tool

The currently selected tool.

x number

Mouse x-coordinate (in canvas coordinates).

y number

Mouse y-coordinate (in canvas coordinates).