mousePosition property

GPoint mousePosition

Returns the position of the mouse in the local coordinate system of this object. The mouse position is updated every frame, so this method returns the current mouse position relative to the top-left corner of this object.

Throws an error if the object is not currently added to the Stage.

Implementation

GPoint get mousePosition {
  if (!inStage) {
    throw 'To get mousePosition, the object needs to be in the Stage.';
  }
  return globalToLocal(_sHelperPoint.setTo(
    stage!.pointer!.mouseX,
    stage!.pointer!.mouseY,
  ));
}