OnClientGUIDoubleClick: Difference between revisions
Jump to navigation
Jump to search
OpenIDUser32 (talk | contribs) No edit summary |
m (Add note for "state" argument) |
||
(5 intermediate revisions by 4 users not shown) | |||
Line 8: | Line 8: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
*'''button:''' the name of the mouse button that the GUI element was double clicked with. | *'''button:''' the name of the mouse button that the GUI element was double clicked with. | ||
*'''state:''' the state of the mouse button. | *'''state:''' the state of the mouse button. Can be ''down'' or ''up''. '''Please note currently only the up state is supported.''' | ||
*'''absoluteX:''' the X position of the mouse cursor, in pixels, measured from the left side of the screen. | *'''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. | *'''absoluteY:''' the Y position of the mouse cursor, in pixels, measured from the top of the screen. | ||
Line 20: | Line 20: | ||
addEventHandler( "onClientResourceStart", getResourceRootElement( ), | addEventHandler( "onClientResourceStart", getResourceRootElement( ), | ||
function ( ) | function ( ) | ||
gridList = guiCreateGridList( 10, 200, 100, 50, false ) | gridList = guiCreateGridList( 10, 200, 100, 50, false ) -- create a gridlist | ||
local col = guiGridListAddColumn( gridList, "Players", .9 ) | local col = guiGridListAddColumn( gridList, "Players", .9 ) -- add "Players" column | ||
local players = getElementsByType( "player" ) | local players = getElementsByType( "player" ) | ||
for i, plr in pairs( players ) do -- loop through the table of players | for i, plr in pairs( players ) do -- loop through the table of players | ||
local row = guiGridListAddRow( gridList ); -- add row for player | local row = guiGridListAddRow( gridList ); -- add row for player | ||
guiGridListSetItemText( gridList, row, col, getPlayerName( plr ), false, false ) | guiGridListSetItemText( gridList, row, col, getPlayerName( plr ), false, false ) -- change the text of the added row | ||
end | end | ||
addEventHandler( "onClientGUIDoubleClick", gridList, doubleClickedName, false ) | addEventHandler( "onClientGUIDoubleClick", gridList, doubleClickedName, false ) | ||
end | end | ||
); | ); | ||
Line 35: | Line 35: | ||
function doubleClickedName( ) | function doubleClickedName( ) | ||
local selectedRow, selectedCol = guiGridListGetSelectedItem( gridList ); -- get double clicked item in the gridlist | local selectedRow, selectedCol = guiGridListGetSelectedItem( gridList ); -- get double clicked item in the gridlist | ||
local playerName = guiGridListGetItemText( gridList, selectedRow, selectedCol ) | local playerName = guiGridListGetItemText( gridList, selectedRow, selectedCol ) -- get its text | ||
outputChatBox( "You double-clicked: " .. playerName ) | outputChatBox( "You double-clicked: " .. playerName ) -- display the text taken from gridlist | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[pl:onClientGUIDoubleClick]] | |||
==See Also== | ==See Also== | ||
{{GUI_events}} | {{GUI_events}} | ||
===Client event functions=== | ===Client event functions=== | ||
{{Client_event_functions}} | {{Client_event_functions}} |
Latest revision as of 07:08, 10 February 2024
This event is fired when the user double clicks a GUI element. Doesn't work with buttons.
Parameters
string button, string state, int absoluteX, int absoluteY
- button: the name of the mouse button that the GUI element was double clicked with.
- state: the state of the mouse button. Can be down or up. Please note currently only the up state is supported.
- 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 that was double clicked.
Example
This example displays in chatbox name of double-clicked player in a gridlist.
addEventHandler( "onClientResourceStart", getResourceRootElement( ), function ( ) gridList = guiCreateGridList( 10, 200, 100, 50, false ) -- create a gridlist local col = guiGridListAddColumn( gridList, "Players", .9 ) -- add "Players" column local players = getElementsByType( "player" ) for i, plr in pairs( players ) do -- loop through the table of players local row = guiGridListAddRow( gridList ); -- add row for player guiGridListSetItemText( gridList, row, col, getPlayerName( plr ), false, false ) -- change the text of the added row end addEventHandler( "onClientGUIDoubleClick", gridList, doubleClickedName, false ) end ); function doubleClickedName( ) local selectedRow, selectedCol = guiGridListGetSelectedItem( gridList ); -- get double clicked item in the gridlist local playerName = guiGridListGetItemText( gridList, selectedRow, selectedCol ) -- get its text outputChatBox( "You double-clicked: " .. playerName ) -- display the text taken from gridlist 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