Toggle

Hey guys, I was wondering if there was a way to toggle a VGUI Dframe using F4 and if so how? by toggle I mean draw it when F4 is pressed and if it’s pressed again remove it. Thanks


(User was banned for this post ("Undescriptive thread title" - Gran PC))

Its on the wiki…

[editline]11th February 2013[/editline]

That does not toggle.

[lua]function GM:ShowSpare2(ply)
if !IsF4Open then
IsF4Open = true
–Open menu
else
IsF4Open = false
–Close menu
end
end[/lua]

Sorry for no formatting, I’m on my phone.

Thanks for that! but I’m just wondernig how to actually close the menu, I know that panel:Remove() works but how would I call it?

Don’t kill me since I don’t know all the VGUI functions

You can try use Panel:SetVisible

… if it doesn’t work … you can remove and rebuild it later.
[lua]
local Toggle = 0
–When you press F4–
Toggle = 1-Toogle
if(Toggle) then
local Menu = vgui.Create(“DFrame”)
Menu:MakePopup()
else
Menu:Remove( )
end
[/lua]