• Press F1 again to close derma frame
    11 replies, posted
I open my menu with F1, but it won't close if i press F1 again, and i need to hit the close button, how do i make so it closes when i press f1 again ? here is my code: [CODE]// Start of Main Frame MainMenuFrame = vgui.Create( "DFrame" ) MainMenuFrame:SetSize( 1000, 600 ) MainMenuFrame:SetTitle("Comingsoon Menu "..Version ) MainMenuFrame:Center( true ) MainMenuFrame:SetVisible( true ) MainMenuFrame:SetDraggable( false ) MainMenuFrame:MakePopup() MainMenuFrame.Paint = function() draw.RoundedBox( 8, 0, 0, MainMenuFrame:GetWide(), MainMenuFrame:GetTall(), Color( 0, 0, 0, 180) ) end // End of Main Frame[/CODE]
Try something like this, it's efficient too because you don't recreate the panel everytime you open it. [code] local myframe local function CreateFrame() /*create frame here*/ myframe = vgui.Create("DFrame") myfr... myframe:SetDeleteOnClose(false) // Required, is otherwise removed when we do :Close, or close it with X button end concommand.Add("toggleframe", function() if not myframe then // If it doesn't exist yet CreateFrame() return end if myframe:IsVisible() then myframe:Close() else myframe:SetVisible(true) end end) [/code]
[QUOTE=Donkie;40640969]Try something like this, it's efficient too because you don't recreate the panel everytime you open it. [code] local myframe local function CreateFrame() /*create frame here*/ myframe = vgui.Create("DFrame") myfr... myframe:SetDeleteOnClose(false) // Required, is otherwise removed when we do :Close, or close it with X button end concommand.Add("toggleframe", function() if not myframe then // If it doesn't exist yet CreateFrame() return end if myframe:IsVisible() then myframe:Close() else myframe:SetVisible(true) end end) [/code][/QUOTE] This don't work, and its a complicated way to do that... or i am just dumb.
It's not complicated, toggleframe should be bound to the F1 key if you haven't already. Give us the code you got.
[CODE]function GM:ShowHelp( ply ) ply:ConCommand("vbtdm_old_menu ") end[/CODE]
EDITED: Nevermind
I can't from work but why don't you look at the pointshop client side code. I know with it you can open and close the menu with f3.
[QUOTE=Caratt;40641075]I can't from work but why don't you look at the pointshop client side code. I know with it you can open and close the menu with f3.[/QUOTE] beacouse i don't know where to find it, tried google.
Show us the clientside code too.
[QUOTE=Donkie;40641956]Show us the clientside code too.[/QUOTE] I am learning lua, trying to learn, can you explain a bit more what file should i show you?
Well, I assumed you adapted your code into my code I gave you, could you show me that?
[QUOTE=Donkie;40642918]Well, I assumed you adapted your code into my code I gave you, could you show me that?[/QUOTE] Ehh, i don't need this anymore, just made a huge button with function: TestingPanel:Close() and it works
Sorry, you need to Log In to post a reply to this thread.