Difference between revisions of "Global Command: setCursorPos"

From The Official Visionaire Studio: Adventure Game Engine Wiki
Line 1: Line 1:
<div class="toccolours mw-collapsible mw-collapsed tbl-ds">
+
Sets the mouse cursor to the {x,y} position provided.
<span class="bold">Function History</span>
 
<div class="mw-collapsible-content">
 
<div class="alt-bg">Available since v3.3</div>
 
</div></div>
 
  
 +
Note that the coordinates must be provided in relation to the screen instead of in relation to the scene. This difference matters if your scene is larger than your screen resolution and thus scrollable.
  
Sets position (absolute) of the mouse cursor to the x,y position provided.
+
{| class="ts"
 +
|-
 +
| style="width:15%" | Related functions
 +
| [[Global Command: getCursorPos|getCursorPos]]
 +
|}
  
  
Syntax:
+
== Syntax ==
<syntaxhighlight>
+
<syntaxhighlight lang="lua">
 
setCursorPos(pos)
 
setCursorPos(pos)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
  
Example:
+
== Parameters ==
<syntaxhighlight>
 
-- let's set mouse cursor to 240 by 480
 
setCursorPos({x=240,y=480})
 
  
-- you could of course use variables instead...
+
{| class="ts"
local cPos = {x=240,y=480}
+
|-
setCursorPos(cPos)
+
! style="width:15%" | Parameter
-- or ...
+
! style="width:15%" | Type/Structure
setCursorPos({x=cPos.x,y=cPos.y})
+
! Description
</syntaxhighlight>
+
|-
 +
| pos
 +
| table {x=int,y=int}
 +
("t_point")
 +
| The position where the mouse cursor should be be moved to.
 +
|}
  
  
 
+
== Return values ==
<span class="bold underline">Arguments</span>
 
 
 
<span class="bold">pos</span>: point (x,y) <br/>
 
The position where the mouse cursor should be be moved to. {x=int,y=int}
 
 
 
 
 
<span class="bold underline">Flags</span>
 
  
 
none
 
none
  
  
<span class="bold underline">Return</span>
+
== Examples ==
  
none
+
'''Example 1:''' Set the mouse cursor to position {240,480} of the screen.
 +
<syntaxhighlight lang="lua">
 +
-- Pass a "t_point" table to the function
 +
setCursorPos({x=240,y=480})
  
 
+
-- You could use a variable instead
{| style="background: #f0f0f0; border: 1px dashed darkgrey" width="100%"
+
local cPos = {x=240,y=480}
|-
+
setCursorPos(cPos)
|<span class="bold">Relevant Pages</span>: [[GetCursorPos_(CMS)|getCursorPos]]
+
</syntaxhighlight>
|}
+
{{toc}}

Revision as of 16:32, 2 May 2023

Sets the mouse cursor to the {x,y} position provided.

Note that the coordinates must be provided in relation to the screen instead of in relation to the scene. This difference matters if your scene is larger than your screen resolution and thus scrollable.

Related functions getCursorPos


Syntax

setCursorPos(pos)


Parameters

Parameter Type/Structure Description
pos table {x=int,y=int}

("t_point")

The position where the mouse cursor should be be moved to.


Return values

none


Examples

Example 1: Set the mouse cursor to position {240,480} of the screen.

-- Pass a "t_point" table to the function
setCursorPos({x=240,y=480})

-- You could use a variable instead
local cPos = {x=240,y=480}
setCursorPos(cPos)