OnClientGUIDoubleClick: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 16: | Line 16: | ||
==Example== | ==Example== | ||
This example displays in chatbox name of double-clicked player in a gridlist. | |||
<syntaxhighlight lang="lua"> | |||
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( "onClientDoubleClick", gridList, doubleClickedName, false ); | |||
end | |||
); | |||
function doubleClickedName( ) | |||
local selectedRow, selectedCol = guiGridListGetSelectedItem( gridList ); -- get double clicked item in the gridlist | |||
local playerName = guiGridListGetItemText( gridList, selectedRow, selectedRow ); -- get its text | |||
outputChatBox( "You double-clicked: " .. playerName ); -- display the text taken from gridlist | |||
end | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 28: | Line 47: | ||
[[Category:Incomplete Event]] | [[Category:Incomplete Event]] | ||
Revision as of 17:45, 5 October 2009
This event is fired when the user double clicks a GUI element.
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. "down" or "up".
- 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( "onClientDoubleClick", gridList, doubleClickedName, false ); end ); function doubleClickedName( ) local selectedRow, selectedCol = guiGridListGetSelectedItem( gridList ); -- get double clicked item in the gridlist local playerName = guiGridListGetItemText( gridList, selectedRow, selectedRow ); -- get its text outputChatBox( "You double-clicked: " .. playerName ); -- display the text taken from gridlist end
See Also
GUI events
Input
GUI
- onClientGUIAccepted
- onClientGUIBlur
- onClientGUIChanged
- onClientGUIClick
- onClientGUIComboBoxAccepted
- onClientGUIDoubleClick
- onClientGUIFocus
- onClientGUIMouseDown
- onClientGUIMouseUp
- onClientGUIMove
- onClientGUIScroll
- onClientGUISize
- onClientGUITabSwitched
- onClientMouseEnter
- onClientMouseLeave
- onClientMouseMove
- onClientMouseWheel