GuiGridListGetSelectedItems: Difference between revisions
Jump to navigation
Jump to search
(Fixed completely useless example) |
(Added note about this function being weird / buggy) |
||
Line 2: | Line 2: | ||
__NOTOC__ | __NOTOC__ | ||
This function returns the items selected in the specified [[Element/GUI/Gridlist|grid list]]. | This function returns the items selected in the specified [[Element/GUI/Gridlist|grid list]]. | ||
Note that for some reason the column ID is 1 lower than it should be, for example 0 is returned but if you try and get the text for column 0 there is nothing, but column 1 has what you clicked on. | |||
==Syntax== | ==Syntax== | ||
Line 30: | Line 32: | ||
if everything was successful or ''false'' if invalid arguments were passed. | if everything was successful or ''false'' if invalid arguments were passed. | ||
==Example== | |||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
Line 46: | Line 49: | ||
local selected = guiGridListGetSelectedItems(gridlistPlayers) | local selected = guiGridListGetSelectedItems(gridlistPlayers) | ||
for i, data in ipairs(selected) do -- Loops through all selected items | for i, data in ipairs(selected) do -- Loops through all selected items | ||
outputChatBox(guiGridListGetItemText(gridlistPlayers, data["row"], 1)) -- Shows player name of selected players | |||
end | end | ||
end | end |
Revision as of 16:00, 3 February 2018
This function returns the items selected in the specified grid list.
Note that for some reason the column ID is 1 lower than it should be, for example 0 is returned but if you try and get the text for column 0 there is nothing, but column 1 has what you clicked on.
Syntax
table guiGridListGetSelectedItems ( element gridList )
Required Arguments
- gridList: The grid list which selected items you want to retrieve.
Returns
Returns a table over the selected items in the grid list in this format:
table = { [1] = { ["column"], -- has the first selected item's column ID ["row"] -- has the first selected item's row ID }, [2] = { ["column"],-- has the second selected item's column ID ["row"] -- has the second selected item's row ID }, ... }
if everything was successful or false if invalid arguments were passed.
Example
Example
-- This example creates a grid list of all players, clicking "Selected" button will then use guiGridListGetSelectedItems to show all selected items. playerWindow = guiCreateWindow(526, 230, 291, 284, "", false) gridlistPlayers = guiCreateGridList(9, 23, 272, 201, false, playerWindow) guiGridListAddColumn(gridlistPlayers, "Players", 0.9) guiGridListSetSelectionMode(gridlistPlayers, 1) -- So can select many players for _, players in ipairs(getElementsByType("player")) do local row = guiGridListAddRow(gridlistPlayers) guiGridListSetItemText(gridlistPlayers, row, 1, getPlayerName(players), false, false) end buttonSelectedPlayer = guiCreateButton(9, 227, 272, 20, "Selected", false, playerWindow) function seeSelected() local selected = guiGridListGetSelectedItems(gridlistPlayers) for i, data in ipairs(selected) do -- Loops through all selected items outputChatBox(guiGridListGetItemText(gridlistPlayers, data["row"], 1)) -- Shows player name of selected players end end addEventHandler("onClientGUIClick", buttonSelectedPlayer, seeSelected, false)
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