From GMod Wiki
Function |
Syntax |
DListView.OnRowSelected( Panel DPanel panel, Integer line]] ) |
Description: |
Run when a row is selected. Similar to DListView:OnClickLine, without ruining the highlighting
library = DListView |
Returns: |
nil |
Realm: |
|
BBCode Link: |
[b][url=http://wiki.garrysmod.com/?title=DListView.OnRowSelected]DListView.OnRowSelected [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Example
Description | Prints the value of the first column on a clicked line in a DListView |
Used on | |
Code | -- Create a DFrame
frame = vgui.Create("DFrame")
frame:SetSize(ScrW() / 2 , ScrH() / 2)
frame:SetTitle("DListView testing")
frame:Center()
frame:MakePopup()
-- Create a DListView
lView = vgui.Create("DListView")
lView:SetParent(frame)
lView:SetPos(5 , 20)
lView:SetSize(frame:GetWide() - 10 , frame:GetTall() - 25)
lView:AddColumn("Name")
lView:AddColumn("Kills")
lView.OnRowSelected = function( panel , line )
RunConsoleCommand("Say" , panel:GetLine(line):GetValue(1))
end
for k , v in pairs(player.GetAll()) do -- Lets loop through the players and add their name and kills
lView:AddLine(v:Nick() , v:Frags()) -- Add a line to the listview, with the player's name in the first column, kills in the second
end
|
Output | (In game chat)¦FlapJack¦: Trippeh |
Additional Notes
Anything you want to interact with the contents of a DListView without ruining the highlighting effect.