executing a function when a vgui frame gets closed

Hi, I’d want to make a function, something like
function Button:DoClick()

but instead of being run when the button is pressed, i want it to run when a frame is closed, so something like

function Frame:IsClosed()

Whats the fucntion?

Does the button close the frame? Anyway,

there’s no function (that I know of) for that. Maybe you could try overriding panel:Remove (it might be panel:Close for DPanels) to run your shizz.



local old = PANEL.Remove
function PANEL:Remove( )

run_stuff( )
old( self )

end


If that doesn’t work then try changing Remove to Close.

I get this error HLTF\gamemode\shared.lua:35: function arguments expected near ‘function’
[lua]GM.Name = “Half Life 2: Team Fortress”
GM.Author = “Tera”
GM.Email = “gabrycir@hotmail.it”

DeriveGamemode( “base” )

team.SetUp( 1, “Combine”, Color( 0, 50, 200, 255 ) )
team.SetUp( 2, “Resistance”, Color( 200, 0, 0, 255 ) )

function change_model_combine()
local ply = LocalPlayer()
ply:SetModel(“models/combine_soldier.mdl”)
end

function classchange()
Msg (“M HAS BEEN PRESD”)

if CLIENT then
	local Frame = vgui.Create("Frame");
	Frame:SetSize(200, 200)
	Frame:SetPos((ScrW()/2)-100, (ScrH()/2)-100)
	Frame:SetVisible(true)
	Frame:MakePopup()
	Frame:PostMessage("SetTitle", "text", "This is the title")
	
	local Button = vgui.Create("Button", Frame)
	Button:SetText("Click me")
	Button:SetPos(30, 100)
	Button:SetWide(100)
	function Button:DoClick()
		change_model_combine()
		Frame:Close()
		frameopen = false
	local old = PANEL:Remove
	function PANEL:Remove( )
		frameopen = false
		old( self )
		end
	end
end

end

frameopen = false

local function Think( )

if( input.IsKeyDown( KEY_M ) and frameopen ~= true ) then
	
	-- m key was pressed
	
	frameopen = true
	classchange()
	
elseif( keydown == true ) then
	
	
	
end

end
hook.Add( “Think”, “CheckKeyInput”, Think );
[/lua]

[lua]
local old = PANEL.Remove
function PANEL:Remove( self )

run_stuff( )
old( self )

end
[/lua]

Try that.

Also, you have put your function inside of it, right?