OnClientCursorMove: Difference between revisions
Jump to navigation
Jump to search
ThePiotrek (talk | contribs) mNo edit summary |
(Replace to predefined variables.) |
||
(One intermediate revision by one other user not shown) | |||
Line 21: | Line 21: | ||
This example creates a text label at the bottom of the screen which displays the mouse position in pixels. | This example creates a text label at the bottom of the screen which displays the mouse position in pixels. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
addEventHandler( "onClientResourceStart", | addEventHandler( "onClientResourceStart", resourceRoot, | ||
function ( ) | function ( ) | ||
textLabel = guiCreateLabel( 0, .9, 1, .1, "X: -; Y: -", true ); | textLabel = guiCreateLabel( 0, .9, 1, .1, "X: -; Y: -", true ); | ||
Line 28: | Line 28: | ||
); | ); | ||
addEventHandler( "onClientCursorMove", | addEventHandler( "onClientCursorMove", root, | ||
function ( _, _, x, y ) | function ( _, _, x, y ) | ||
guiSetText( textLabel, "X: " .. tostring( x ) .. "; Y: ".. tostring( y ) ) | guiSetText( textLabel, "X: " .. tostring( x ) .. "; Y: ".. tostring( y ) ) | ||
Line 38: | Line 38: | ||
==See Also== | ==See Also== | ||
{{GUI_events}} | {{GUI_events}} | ||
===Client event functions=== | ===Client event functions=== | ||
{{Client_event_functions}} | {{Client_event_functions}} |
Latest revision as of 05:58, 12 July 2023
This event is called by the root element whenever the cursor is moved over the screen, by the player. It returns information about the world coordinates as well as the screen coordinates of where the player moved the cursor.
The difference between this event and onClientMouseMove, is that the latter is actually called by GUI elements. This is to prevent double calling of onClientCursorMove, as onClientCursorMove is always called.
Parameters
float cursorX, float cursorY, int absoluteX, int absoluteY, float worldX, float worldY, float worldZ
- cursorX: the relative X coordinate of the mouse cursor. 0 = left side of the screen, 1 = right side.
- cursorY: the relative Y coordinate of the mouse cursor. 0 = top of the screen, 1 = bottom.
- absoluteX: the X coordinate of the mouse cursor, in pixels, measured from the left side of the screen.
- absoluteY: the Y coordinate of the mouse cursor, in pixels, measured from the top of the screen.
- worldX, worldY, worldZ: the 3D in-game world coordinates that the cursor is pointing at.
Source
The source of this event is the root element.
Example
This example creates a text label at the bottom of the screen which displays the mouse position in pixels.
addEventHandler( "onClientResourceStart", resourceRoot, function ( ) textLabel = guiCreateLabel( 0, .9, 1, .1, "X: -; Y: -", true ); guiLabelSetHorizontalAlign( textLabel, "center" ); end ); addEventHandler( "onClientCursorMove", root, function ( _, _, x, y ) guiSetText( textLabel, "X: " .. tostring( x ) .. "; Y: ".. tostring( y ) ) end );
See Also
Input
GUI
- onClientGUIAccepted
- onClientGUIBlur
- onClientGUIChanged
- onClientGUIClick
- onClientGUIComboBoxAccepted
- onClientGUIDoubleClick
- onClientGUIFocus
- onClientGUIMouseDown
- onClientGUIMouseUp
- onClientGUIMove
- onClientGUIScroll
- onClientGUISize
- onClientGUITabSwitched
- onClientMouseEnter
- onClientMouseLeave
- onClientMouseMove
- onClientMouseWheel
Client event functions
- triggerLatentServerEvent
- triggerServerEvent
- Shared
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled