feature request: optionally deleting the whole chain of event
handlers, when window is deleted
chris
cb at delta-h.de
Sun Feb 3 23:46:27 PST 2008
On 1 Feb., 18:15, va... at wxwidgets.org (Vadim Zeitlin) wrote:
> On Fri, 1 Feb 2008 03:12:07 -0800 (PST) chris <c... at delta-h.de> wrote:
>
> c> this feature would need an additional flag when adding a handler to a
> c> window:
> c>
> c> void wxWindowBase::PushEventHandler(wxEvtHandler *handler, const bool&
> c> shouldBeDeletedWithWindow = false);
>
> Unless I'm missing something, this would require adding a field to each
> wxEvtHandler (and hence each wxWindow) indicating whether it should be
> deleted with the window it is associated with. I don't think it's a good
> trade-off.
Or a field in every wxWindowBase, indicating that 'all' handlers in
the chain should be deleted. Since only wxWindow(Base) offers the push
and pop methods it should be included in this class.
This wouldn't affect the interface that we have right now.
>
> The solution I use when I need to push-and-forget an event handler is to
> catch window destruction event in this handler and do "delete this" from
> it.
I do it quite similiar: I have one instance of an manager object,
derived from wxEvtHandler. Here i register all my dialogs etc. which
get extra event handling.
When this dialog is closed i delete all corresponding event handlers.
That's because I dont want to 'call delete' this anywhere.
But using the flag mentioned above would be a quite cleaner and more
flexible solution. We wouldn't be restricted to the windows wich are
sending an event, when they are closed and we wouldn't have to watch
for wxEVT_CLOSE_WINDOW all the time.
> I think it would be nice to have a base class implementing this in a
> reusable manner so that you could get this functionality by just deriving
> from this wxAutoDeletedEventHandler class.
>
> Regards,
> VZ
>
> --
> TT-Solutions: wxWidgets consultancy and technical support
> http://www.tt-solutions.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscr... at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-h... at lists.wxwidgets.org
More information about the wx-users
mailing list