DermaWindow Closed Hook?

Hey guys,

I can’t seem to find a solution for this. Is there a way to hook to check if the derma window the player has opened, is closed? Such as the player presses “X” on the window to close it.
Since I’d like to do a action after this is triggered.

Thanks!

Not so much a hook, but if you have the variable of the window in question, you can do:

[lua]
local old = Window.Close
Window.Close = function() /code here/ old( Window ) end
[/lua]

and just call all your stuff in there.

Actually, this method is terrible, use what the poster below suggested

**[Lua/Events/Panel

http://gmodwiki.net/favicon.ico](http://gmodwiki.net/Lua/Events/Panel)**

Specifically, this **[Lua/Events/Panel/OnDeletion

http://gmodwiki.net/favicon.ico](http://gmodwiki.net/Lua/Events/Panel/OnDeletion)**

Isn’t OnDeletion broken?

I don’t know, I haven’t used it for a long time. Perhaps someone should just do a quick test?

If you’re using a DFrame, you can overwrite the close button.

This is from DPanel:Init()
[lua]self.btnClose.DoClick = function ( button ) self:Close() end[/lua]

So if you have the frame’s variable, you can do this as you create the frame:
[lua]
frame.btnClose.DoClick = function ( button )
–Do your stuff here.
frame:Close()
end
[/lua]

I’ve always done it the first way, because I didn’t know of OnDeletion. However, I would assume OnDeletion doesn’t fire if you’ve done dframe:SetDeleteOnClose(false), in which case you would need to go with the first method or something similar.