MouseArea

MouseArea

A MouseArea is an invisible widget that is typically used in conjunction with a visible widget in order to provide mouse handling for that.

Information about the mouse position is provided via events such as click, mousedown, mousemove and mouseup.

Constructor

new MouseArea()

Initializes a new instance of MouseArea

Extends

Members

height :Number

Overrides:

This property holds the height of the widget.

Type:
  • Number

opacity :Number

Overrides:

This property holds the opacity of the widget. The valid range of opacity is from 1.0 (completely opaque) to 0.0 (completely transparent).

Type:
  • Number

(readonly) pressed :Boolean

This property is read-only and holds whether any mouse buttons are currently pressed.

Type:
  • Boolean

rotation :Number

Overrides:

This property holds the rotation of the widget in degrees clockwise.

Type:
  • Number

width :Number

Overrides:

This property holds the width of the widget.

Type:
  • Number

x :Number

Overrides:

This property holds the x coordinate of the widget relative to its parent.

Type:
  • Number

y :Number

Overrides:

This property holds the y coordinate of the widget relative to its parent.

Type:
  • Number

Events

click

This event is fired when there is a click. A click is defined as a press (e.g. mouse button down) followed by a release (e.g. mouse button up), both inside the MouseArea.

Type:
Example
var mouseArea = new MouseArea();
this.widget.add(mouseArea);

mouseArea.on('click', (mouseEvent) => {
  // do something
});

mousedown

This event is fired when a mouse button is pressed inside the MouseArea.

Type:
Example
var mouseArea = new MouseArea();
this.widget.add(mouseArea);

mouseArea.on('mousedown', (mouseEvent) => {
  // do something
});

mousemove

This event is fired when the position of a mouse pointer is changed while a mouse button is pressed. Note that a MouseArea must receive a mousedown event first then (can receive) mousemove events followed.

Type:
Example
var mouseArea = new MouseArea();
this.widget.add(mouseArea);

mouseArea.on('mousemove', (mouseEvent) => {
  // do something
});

mouseup

This event is fired when a mouse button is released. Note that mouseup events are the counterpoint to mousedown events, that is, a MouseArea must receive a mousedown event first then (can receive) a mouseup event followed.

Type:
Example
var mouseArea = new MouseArea();
this.widget.add(mouseArea);

mouseArea.on('mouseup', (mouseEvent) => {
  // do something
});