Moves the mouse cursor to a specified point relative to the display origin (the upper-left corner of the display).


func CGDisplayMoveCursorToPoint(_ display: CGDirectDisplayID, _ point: CGPoint) -> CGError



The identifier of the display to be accessed.


The coordinates of a point in local display space. The origin is the upper-left corner of the specified display.

Return Value

A result code. See Core Graphics Data Types and Constants.


No events are generated as a result of this move. Points that lie outside the desktop are clipped to the desktop.

See Also

Controlling the Mouse Cursor

func CGDisplayHideCursor(CGDirectDisplayID) -> CGError

Hides the mouse cursor, and increments the hide cursor count.

func CGDisplayShowCursor(CGDirectDisplayID) -> CGError

Decrements the hide cursor count, and shows the mouse cursor if the count is 0.

func CGCursorIsVisible() -> boolean_t

Returns a Boolean value indicating whether the mouse cursor is visible.

func CGCursorIsDrawnInFramebuffer() -> boolean_t

Returns a Boolean value indicating whether the mouse cursor is drawn in framebuffer memory.

func CGAssociateMouseAndMouseCursorPosition(boolean_t) -> CGError

Connects or disconnects the mouse and cursor while an application is in the foreground.

func CGWarpMouseCursorPosition(CGPoint) -> CGError

Moves the mouse cursor without generating events.

func CGGetLastMouseDelta() -> (x: Int32, y: Int32)

Reports the change in mouse position since the last mouse movement event received by the application.