GuiGridListGetItemColor: Difference between revisions
Jump to navigation
Jump to search
(Created page with '{{Client function}} __NOTOC__ This function gets the color of a gridlist item. ==Syntax== <syntaxhighlight lang="lua"> int int int int guiGridListGetItemColor ( element gridList, int rowIndex…') |
No edit summary |
||
Line 17: | Line 17: | ||
==Example== | ==Example== | ||
<section name="Client" class="client" show="true"> | |||
This example creates a player list on the right of the screen and fills it with players online and sets the grid list item color according to their nametag color. | |||
When the player clicks on a grid list item, it'll output the color of it. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | function createPlayerList ( ) | ||
--Create the grid list element | |||
local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) | |||
--Create a players column in the list | |||
addEventHandler ( "onClientGUIClick", playerList, onGridListClick, false ) | |||
local column = guiGridListAddColumn( playerList, "Player", 0.85 ) | |||
if ( column ) then --If the column has been created, fill it with players | |||
for id, player in ipairs ( getElementsByType ( "player" ) ) do | |||
local row = guiGridListAddRow ( playerList ) | |||
local r, g, b = getPlayerNametagColor ( player ) -- We get the player nametag color. | |||
guiGridListSetItemText ( playerList, row, column, getPlayerName ( player ), false, false ) | |||
guiGridListSetItemColor ( playerList, row, column, r, g, b ) -- We set the grid list item color to the returned values of getPlayerNametagColor. | |||
end | |||
end | |||
end | |||
addEventHandler ( "onClientResourceStart", resourceRoot, createPlayerList ) | |||
function onGridListClick ( ) | |||
local row, col = guiGridListGetSelectedItem(source) | |||
if ( row and col and row ~= -1 and col ~= -1 ) then | |||
local r, g, b = guiGridListGetItemColor ( source, row, col ) | |||
outputChatBox ( "Red: ".. r, 255, 0, 0 ) | |||
outputChatBox ( "Green: ".. g, 0, 255, 0 ) | |||
outputChatBox ( "Blue: ".. b, 0, 0, 255 ) | |||
end | |||
end | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{GUI functions}} | {{GUI functions}} | ||
Revision as of 00:36, 27 March 2012
This function gets the color of a gridlist item.
Syntax
int int int int guiGridListGetItemColor ( element gridList, int rowIndex, int columnIndex )
Required Arguments
- gridList: The grid list element
- rowIndex: Row ID
- columnIndex: Column ID
Returns
Returns four int values, representing the amount of red, green, blue and alpha if successful. false otherwise.
Example
Click to collapse [-]
ClientThis example creates a player list on the right of the screen and fills it with players online and sets the grid list item color according to their nametag color. When the player clicks on a grid list item, it'll output the color of it.
function createPlayerList ( ) --Create the grid list element local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) --Create a players column in the list addEventHandler ( "onClientGUIClick", playerList, onGridListClick, false ) local column = guiGridListAddColumn( playerList, "Player", 0.85 ) if ( column ) then --If the column has been created, fill it with players for id, player in ipairs ( getElementsByType ( "player" ) ) do local row = guiGridListAddRow ( playerList ) local r, g, b = getPlayerNametagColor ( player ) -- We get the player nametag color. guiGridListSetItemText ( playerList, row, column, getPlayerName ( player ), false, false ) guiGridListSetItemColor ( playerList, row, column, r, g, b ) -- We set the grid list item color to the returned values of getPlayerNametagColor. end end end addEventHandler ( "onClientResourceStart", resourceRoot, createPlayerList ) function onGridListClick ( ) local row, col = guiGridListGetSelectedItem(source) if ( row and col and row ~= -1 and col ~= -1 ) then local r, g, b = guiGridListGetItemColor ( source, row, col ) outputChatBox ( "Red: ".. r, 255, 0, 0 ) outputChatBox ( "Green: ".. g, 0, 255, 0 ) outputChatBox ( "Blue: ".. b, 0, 0, 255 ) end end
See Also
General functions
- guiBringToFront
- getChatboxLayout
- getChatboxCharacterLimit
- guiCreateFont
- guiBlur
- guiFocus
- guiGetAlpha
- guiGetCursorType
- guiGetEnabled
- guiGetFont
- guiGetInputEnabled
- guiGetInputMode
- guiGetPosition
- guiGetProperties
- guiGetProperty
- guiGetScreenSize
- guiGetSize
- guiGetText
- guiGetVisible
- guiMoveToBack
- guiSetAlpha
- guiSetEnabled
- guiSetFont
- guiSetInputEnabled
- guiSetInputMode
- guiSetPosition
- guiSetProperty
- guiSetSize
- guiSetText
- guiSetVisible
- isChatBoxInputActive
- isConsoleActive
- isDebugViewActive
- isMainMenuActive
- isMTAWindowActive
- isTransferBoxActive
- setChatboxCharacterLimit
- setDebugViewActive
Browsers
Buttons
Checkboxes
Comboboxes
- guiCreateComboBox
- guiComboBoxAddItem
- guiComboBoxClear
- guiComboBoxGetItemCount
- guiComboBoxGetItemText
- guiComboBoxGetSelected
- guiComboBoxIsOpen
- guiComboBoxRemoveItem
- guiComboBoxSetItemText
- guiComboBoxSetOpen
- guiComboBoxSetSelected
Edit Boxes
- guiCreateEdit
- guiEditGetCaretIndex
- guiEditGetMaxLength
- guiEditIsMasked
- guiEditIsReadOnly
- guiEditSetCaretIndex
- guiEditSetMasked
- guiEditSetMaxLength
- guiEditSetReadOnly
Gridlists
- guiCreateGridList
- guiGridListAddColumn
- guiGridListAddRow
- guiGridListAutoSizeColumn
- guiGridListClear
- guiGridListGetColumnCount
- guiGridListGetColumnTitle
- guiGridListGetColumnWidth
- guiGridListGetHorizontalScrollPosition
- guiGridListGetItemColor
- guiGridListGetItemData
- guiGridListGetItemText
- guiGridListGetRowCount
- guiGridListGetSelectedCount
- guiGridListGetSelectedItem
- guiGridListGetSelectedItems
- guiGridListGetSelectionMode
- guiGridListIsSortingEnabled
- guiGridListGetVerticalScrollPosition
- guiGridListInsertRowAfter
- guiGridListRemoveColumn
- guiGridListRemoveRow
- guiGridListSetColumnTitle
- guiGridListSetColumnWidth
- guiGridListSetHorizontalScrollPosition
- guiGridListSetItemColor
- guiGridListSetItemData
- guiGridListSetItemText
- guiGridListSetScrollBars
- guiGridListSetSelectedItem
- guiGridListSetSelectionMode
- guiGridListSetSortingEnabled
- guiGridListSetVerticalScrollPosition
Memos
- guiCreateMemo
- guiMemoGetCaretIndex
- guiMemoGetVerticalScrollPosition
- guiMemoSetVerticalScrollPosition
- guiMemoIsReadOnly
- guiMemoSetCaretIndex
- guiMemoSetReadOnly
Progressbars
Radio Buttons
Scrollbars
Scrollpanes
- guiCreateScrollPane
- guiScrollPaneGetHorizontalScrollPosition
- guiScrollPaneGetVerticalScrollPosition
- guiScrollPaneSetHorizontalScrollPosition
- guiScrollPaneSetScrollBars
- guiScrollPaneSetVerticalScrollPosition
Static Images
Tab Panels
Tabs
Text Labels
- guiCreateLabel
- guiLabelGetColor
- guiLabelGetFontHeight
- guiLabelGetTextExtent
- guiLabelSetColor
- guiLabelSetHorizontalAlign
- guiLabelSetVerticalAlign