DListView Open a menu

So this is the code i have right now for a Menu.


concommand.Add( "statsmenu", function( )




local frame = vgui.Create( "DFrame" )
frame:SetPos(50,50)
frame:SetSize( 500,500 )
frame:ShowCloseButton(true)
frame:MakePopup()

local lista = vgui.Create( "DListView", frame )
lista:SetMultiSelect( false )
lista:SetPos(0,20)
lista:SetSize(500,500)
lista:AddColumn( "Players" )
lista:AddColumn( "Health" )
lista:AddColumn( "Armor" )
lista:AddColumn( "SteamID" )

for k,v in pairs( player.GetAll() ) do
    lista:AddLine( v:Nick(), v:Health(), v:Armor(), v:SteamID() )
end

end) 

and i need to know is there a way to like when you double click on someone it opens another menu with like HP and stuff and when you for example set the HP to 150 it sets it for the player you clicked on

>Googles “Gmod DListView double click”
First result

ye but i mean like when you double click, it targets the player you double clicked on

Also update on what i have made so far :slight_smile:



local pframe = vgui.Create( "DFrame" )
pframe:SetPos( 50,50 )
pframe:SetSize( 500,520 )
pframe:MakePopup()
pframe:SetTitle( "Target Manager" )
pframe:SetDraggable(false)
pframe:ShowCloseButton(true)
pframe:SetVisible(false)


local frame = vgui.Create( "DFrame" )
frame:SetPos(50,50)
frame:SetSize( 500,555 )
frame:SetVisible(true)
frame:ShowCloseButton(false)
frame:SetDraggable( false )
frame:MakePopup()
frame:SetTitle(" ")

local close = vgui.Create( "DButton", frame )
close:SetPos(10,521)
close:SetTextColor( Color( 255, 255, 255, 255 ) )
close:SetText( "Close Menu" )
close:SetSize(475,30)
	close.Paint = function() -- The paint function
    surface.SetDrawColor( 255, 0, 0, 255 ) -- What color do You want to paint the button (R, B, G, A)
    surface.DrawRect( 0, 0, close:GetWide(), close:GetTall() ) -- Paint what coords (Used a function to figure that out)
end
close.DoClick = function(  )
frame:Remove()

end

local lista = vgui.Create( "DListView", frame )
lista:SetMultiSelect( false )
lista:SetPos(0,20)
lista:SetSize(500,500)
lista:AddColumn( "Players" )
lista:AddColumn( "Health" )
lista:AddColumn( "Armor" )
lista:AddColumn( "SteamID" )



function DListView:DoDoubleClick( lineID, line)

local pframe = vgui.Create( "DFrame" )
pframe:SetPos( 50,50 )
pframe:SetSize( 500,520 )
pframe:MakePopup()
pframe:SetTitle( "Target Manager" )
pframe:SetDraggable(false)
pframe:ShowCloseButton(true)
pframe:SetVisible(true)
end


for k,v in pairs( player.GetAll() ) do
    lista:AddLine( v:Nick(), v:Health(), v:Armor(), v:SteamID() )
end



Anyone?

That’s not, um… wat

That is not how you would set that function to work, this is how you would do it:
[lua]
lista.DoDoubleClick = function(lineID, line)
local pframe = vgui.Create( “DFrame” )
pframe:SetPos( 50,50 )
pframe:SetSize( 500,520 )
pframe:MakePopup()
pframe:SetTitle( “Target Manager” )
pframe:SetDraggable(false)
pframe:ShowCloseButton(true)
pframe:SetVisible(true)
end
[/lua]

Why are you creating pframe, then frame? There’s almost never a reason to put 2 DFrames on top of each other like that, and never a reason to do so when it’s not parented to one another.

Same goes for your button - It’s not parented, so it’s positioning won’t work properly

As for creating the DListView - You’re not setting a parent, so I doubt it will act as you want it to.
But what are you even trying to do? You’re already adding lines to the DListView with all of the players’ HP and stuff, and what the hell does this mean?

Also -

Please don’t bump after 3 hours, have some patience

it works for me, makes the panel visible asoon as i double click on the thing.

and sorry :3

[editline]14th September 2016[/editline]

Worked for me bte. Maybe your pc

Assuming it somehow worked for you, what is the problem then .-.

i want to know, when i click on a player in the DListView, it targets them and on the menu that pops up i can for example set there health via that then