DListView.OnClickLine

From GMod Wiki

Jump to: navigation, search
Function
Syntax DListView.OnClickLine( Panel DPanel parent, Panel DListView_Line line, Boolean isselected )
Where is this used?
Description:
Runs whenever a line/row is clicked
Returns: nil
Part of Library: DListView
Realm: NewerClient.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=DListView.OnClickLine]DListView.OnClickLine [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionCreates a list that prints what's in the first column of the clicked row.
Used onNewerClient.png
Code
local guipanel = vgui.Create("DFrame") //Create a standard DFrame
guipanel:SetPos(100, 100)
guipanel:SetSize(200, 200)
guipanel:SetTitle("Testing lists")
guipanel:SetDraggable(true)
guipanel:ShowCloseButton(true)
 
local guicmdlist = vgui.Create("DListView",guipanel) //Create a DListView object
guilist:SetPos(5, 5)
guilist:SetSize(150, 150)
guilist:SetMultiSelect(false) //Disallow the selection of multiple items
guilist:AddColumn("Numbers") //Creates a new column
 
for i = 1, 50 do //Adds 50 lines to our list, each with a number 1-50
	guilist:AddLine(tostring(i))
end
 
guilist.OnClickLine = function(parent, line, isselected) //We override the function with our own
	guipanel:SetVisible(false) //Don't allow the action to be performed twice
	print(line:GetValue(1)) //Prints the value of the first column in our line.
end
 
//Shows the DFrame
guipanel:MakePopup()
guipanel:SetVisible(true)
OutputPrints the number (1-50) that you click


Additional Notes

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox