OnClientMouseMove: Difference between revisions
Jump to navigation
Jump to search
(New page: {{Client event}} __NOTOC__ This event is triggered each time the user moves the mouse on top of a GUI element. ==Parameters== <syntaxhighlight lang="lua"> int absoluteX, int absoluteY </syntaxhighlight> * '''ab...) |
|||
Line 13: | Line 13: | ||
==Example== | ==Example== | ||
This example creates a text label at the bottom of the screen that tells player the position of mouse when moved on top of a "TEST WINDOW" (the gui element). | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
addEventHandler( "onClientResourceStart", getResourceRootElement( ), | |||
function ( ) | |||
guiCreateWindow( 10, 200, 200, 150, "TEST WINDOW", false ); | |||
textLabel = guiCreateLabel( 0, .9, 1, .1, "", true ); | |||
guiLabelSetHorizontalAlign( textLabel, "center" ); | |||
end | |||
); | |||
addEventHandler( "onClientMouseMove", getRootElement( ), | |||
function ( x, y ) | |||
if source then | |||
if not guiGetVisible( textLabel ) then guiSetVisible( textLabel, true ) end | |||
guiSetText( textLabel, "X: " .. tostring( x ) .. "; Y: ".. tostring( y ) ) | |||
else | |||
guiSetVisible( textLabel, false ); | |||
end | |||
end | |||
) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 22: | Line 40: | ||
===Client event functions=== | ===Client event functions=== | ||
{{Client_event_functions}} | {{Client_event_functions}} | ||
Revision as of 18:05, 5 October 2009
This event is triggered each time the user moves the mouse on top of a GUI element.
Parameters
int absoluteX, int absoluteY
- absoluteX: the X position of the mouse cursor, in pixels, measured from the left side of the screen.
- absoluteY: the Y position of the mouse cursor, in pixels, measured from the top of the screen.
Source
The source of this event is the GUI element on which the mouse was moved.
Example
This example creates a text label at the bottom of the screen that tells player the position of mouse when moved on top of a "TEST WINDOW" (the gui element).
addEventHandler( "onClientResourceStart", getResourceRootElement( ), function ( ) guiCreateWindow( 10, 200, 200, 150, "TEST WINDOW", false ); textLabel = guiCreateLabel( 0, .9, 1, .1, "", true ); guiLabelSetHorizontalAlign( textLabel, "center" ); end ); addEventHandler( "onClientMouseMove", getRootElement( ), function ( x, y ) if source then if not guiGetVisible( textLabel ) then guiSetVisible( textLabel, true ) end guiSetText( textLabel, "X: " .. tostring( x ) .. "; Y: ".. tostring( y ) ) else guiSetVisible( textLabel, false ); end end )
See Also
GUI events
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