setCursorPosition
Client-side
Server-side
Shared
Pair: getCursorPosition
This function sets the current position of the mouse cursor.
Syntax
bool setCursorPosition ( int cursorX, int cursorY )Required Arguments
- cursorX: Position for the X axis.
- cursorY: Position for the Y axis.
Returns
- bool: result
Returns true if the position has been successfully set, false otherwise.
Code Examples
client
This example sets your cursor position to the center of your screen after using the /cursorpos command.
function centerCursorFunction() -- is cursor showing? if isCursorShowing() then -- get the screen size in pixels local screenX, screenY = guiGetScreenSize()
-- set the cursor position to the center of the screen setCursorPosition(screenX / 2, screenY / 2) else outputChatBox("Your cursor is not showing.") endendaddCommandHandler("cursorpos", centerCursorFunction)