Manual Reference Source
public class | source

Mouse

Constructor Summary

Public Constructor
public

constructor(viewer: Object)

Mouse's constructor.

Member Summary

Public Members
public
public
public
public
public
public
public
public

Method Summary

Public Methods
public

Add a mouse button down callback.

public

Add a mouse move callback.

public

Add a mouse button up callback.

public

Add a mouse wheel callback.

public

Destroy the mouse object.

Public Constructors

public constructor(viewer: Object) source

Mouse's constructor.

Params:

NameTypeAttributeDescription
viewer Object

The viewer object.

Example:

var mouse = viewer.addInput(new Modelo.View.Input.Mouse(viewer));
mouse.addMouseUpListener(function(mouse) {
    if (!mouse.moved) {
         viewer.getCamera().lookTo(mouse.x, mouse.y);
    }
});

Public Members

public button: number source

public delta: number source

public dx: number source

public dy: number source

public moved: boolean source

public pressed: boolean source

public x: number source

public y: number source

Public Methods

public addMouseDownListener(cbk: function(mouse: Object): boolean) source

Add a mouse button down callback. The registered callback will be trigger when a mouse down event happens.

Params:

NameTypeAttributeDescription
cbk function(mouse: Object): boolean

A mouse button-down callback.

public addMouseMoveListener(cbk: function(mouse: Object): boolean) source

Add a mouse move callback. The registered callback will be trigger when a mouse move event happens.

Params:

NameTypeAttributeDescription
cbk function(mouse: Object): boolean

A mouse move callback.

public addMouseUpListener(cbk: function(mouse: Object): boolean) source

Add a mouse button up callback. The callbacks will be executabled in a reversed order which means the callbacks add last will be executed at first. Callbacks takes the mouse object and returns a boolean to indicate whether event has been digested and no need to pass to the following callbacks.

Params:

NameTypeAttributeDescription
cbk function(mouse: Object): boolean

A mouse button-up callback.

public addMouseWheelListener(cbk: function(mouse: Object): boolean) source

Add a mouse wheel callback.

Params:

NameTypeAttributeDescription
cbk function(mouse: Object): boolean

A mouse button wheel callback.

public destroy() source

Destroy the mouse object. This function is not usually called by application. Once mouse object is added to viewer, the viewer will destroy the mouse object when itself gets released.