GuiGridListInsertRowAfter: Difference between revisions
Jump to navigation
Jump to search
JonChappell (talk | contribs) No edit summary |
(Fix incorrect return.) |
||
(14 intermediate revisions by 12 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | {{Client function}} | ||
__NOTOC__ | |||
This allows you to insert a new row after a specified row, and simultaneously set text. Good for inserting new rows in the middle of existing rows. To insert at the top use -1 as row index. | |||
==Syntax== | ==Syntax== | ||
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --> | <!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
int guiGridListInsertRowAfter ( element gridList, int rowIndex ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
{{New feature/item|3.0153|1.5.3|| | |||
<syntaxhighlight lang="lua"> | |||
int guiGridListInsertRowAfter ( element gridList [, int rowIndex, int/string itemText1, int/string itemText2, ... ] ) | |||
</syntaxhighlight> | |||
}} | |||
{{OOP||[[Element/GUI/Gridlist|GuiGridList]]:insertRowAfter}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''gridList:''' The grid list you want to add a row to | |||
*''' | *'''rowIndex:''' Row ID of the row you want to insert the '''new row''' after. | ||
===Optional Arguments=== | |||
===Optional Arguments=== | {{New feature/item|3.0153|1.5.3|| | ||
{{ | *'''itemText1:''' The text for the first column item in the row. Either a string or a number can be passed (use numbers for sorting purposes). | ||
*''' | *'''itemText2:''' The text for the second column item in the row. Either a string or a number can be passed (use numbers for sorting purposes). | ||
*''' | *'''...:''' Item text for any other columns | ||
}} | |||
===Returns=== | ===Returns=== | ||
Returns ''row id'' if the row was successfully added, ''false'' otherwise. | |||
Returns '' | |||
==Example== | ==Example== | ||
This example would create a gridlist then add the current players in the server and if anyone joins, it would insert a row at the bottom. | |||
<syntaxhighlight lang="lua">gridlist = guiCreateGridList(100,100,200,100,false) | |||
guiGridListAddColumn(gridlist,"Players",0.50) | |||
<syntaxhighlight lang="lua"> | for i,v in ipairs(getElementsByType("player"))do | ||
guiGridListSetItemText(gridlist,guiGridListAddRow(gridlist),1,getPlayerName(v),false,false) | |||
end | |||
-- | addEventHandler("onClientPlayerJoin",root,function() | ||
guiGridListSetItemText(gridlist,guiGridListInsertRowAfter(gridlist,guiGridListGetRowCount(gridlist)),1,getPlayerName(source),false,false)--Add row at the bottom of the gridlist and name it the players name | |||
end) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 37: | Line 45: | ||
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --> | <!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --> | ||
{{GUI functions}} | {{GUI functions}} | ||
{{GUI_events}} |
Latest revision as of 06:27, 16 January 2023
This allows you to insert a new row after a specified row, and simultaneously set text. Good for inserting new rows in the middle of existing rows. To insert at the top use -1 as row index.
Syntax
int guiGridListInsertRowAfter ( element gridList, int rowIndex )
int guiGridListInsertRowAfter ( element gridList [, int rowIndex, int/string itemText1, int/string itemText2, ... ] )
OOP Syntax Help! I don't understand this!
- Method: GuiGridList:insertRowAfter(...)
Required Arguments
- gridList: The grid list you want to add a row to
- rowIndex: Row ID of the row you want to insert the new row after.
Optional Arguments
- itemText1: The text for the first column item in the row. Either a string or a number can be passed (use numbers for sorting purposes).
- itemText2: The text for the second column item in the row. Either a string or a number can be passed (use numbers for sorting purposes).
- ...: Item text for any other columns
Returns
Returns row id if the row was successfully added, false otherwise.
Example
This example would create a gridlist then add the current players in the server and if anyone joins, it would insert a row at the bottom.
gridlist = guiCreateGridList(100,100,200,100,false) guiGridListAddColumn(gridlist,"Players",0.50) for i,v in ipairs(getElementsByType("player"))do guiGridListSetItemText(gridlist,guiGridListAddRow(gridlist),1,getPlayerName(v),false,false) end addEventHandler("onClientPlayerJoin",root,function() guiGridListSetItemText(gridlist,guiGridListInsertRowAfter(gridlist,guiGridListGetRowCount(gridlist)),1,getPlayerName(source),false,false)--Add row at the bottom of the gridlist and name it the players name 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
Windows
Input
GUI
- onClientGUIAccepted
- onClientGUIBlur
- onClientGUIChanged
- onClientGUIClick
- onClientGUIComboBoxAccepted
- onClientGUIDoubleClick
- onClientGUIFocus
- onClientGUIMouseDown
- onClientGUIMouseUp
- onClientGUIMove
- onClientGUIScroll
- onClientGUISize
- onClientGUITabSwitched
- onClientMouseEnter
- onClientMouseLeave
- onClientMouseMove
- onClientMouseWheel