• DermaWindow Closed Hook?
    6 replies, posted
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
[b][url=http://gmodwiki.net/Lua/Events/Panel]Lua/Events/Panel[img]http://gmodwiki.net/favicon.ico[/img][/url][/b] Specifically, this [b][url=http://gmodwiki.net/Lua/Events/Panel/OnDeletion]Lua/Events/Panel/OnDeletion[img]http://gmodwiki.net/favicon.ico[/img][/url][/b]
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]
[QUOTE=James xX;42455347]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[/QUOTE] [QUOTE=EvacX;42455400][b][url=http://gmodwiki.net/Lua/Events/Panel]Lua/Events/Panel[img]http://gmodwiki.net/favicon.ico[/img][/url][/b] Specifically, this [b][url=http://gmodwiki.net/Lua/Events/Panel/OnDeletion]Lua/Events/Panel/OnDeletion[img]http://gmodwiki.net/favicon.ico[/img][/url][/b][/QUOTE] 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.
Sorry, you need to Log In to post a reply to this thread.