From: John L. <jla...@gm...> - 2013-08-26 03:15:13
|
On Sun, Aug 25, 2013 at 4:24 PM, Andreas Falkenhahn <an...@fa...>wrote: ... > But how should I do it in wxLua? If I'd derive a whole new class from > wxWindow I'd have to create new bindings for it etc. This all sounds > quite complicated so I'd to know if there is an easier way to hook into > the wxWindow::Destroy method for every wxWindow object created by > wxLua. > > Connecting to wxEVT_DESTROY is probably not sufficient because AFAICS > destruction is already in process when this event is sent, but I'd > like to run my custom code *before* the destruction process is actually > started. > > wxLua only supports using wxEVT_DESTROY. Usually you can handle destroying windows by managing how and who deletes them. wxWidgets only deletes the children of a window when it is destroyed and only top level windows (wxFrame/wxDialog) can be destroyed "by themselves," but you can veto wxEVT_CLOSE events. I would try to refactor your code to work either with wxEVT_DESTROY or manage deletion from the top down by doing what you need to do before calling Destroy() on the window yourself. Regards, John |