Re: [gtkmm] Automatically destroying a dialog
- From: "Timothy M. Shead" <tshead k-3d com>
- To: mcanaleta telefonica net
- Cc: gtkmm-list gnome org
- Subject: Re: [gtkmm] Automatically destroying a dialog
- Date: Tue, 20 Jul 2004 14:18:56 -0700
Marc Canaleta wrote:
I want a dialog to be deleted when it is closed (similar to widgets
created with manage()). The problem is that it isn't modal and I can
have various of them simultanelly, so I must create it using new, and I
don't know where to delete it when it is closed.
You can override the virtual Gtk::Widget::on_delete_event(GdkEventAny*)
method in your dialog class, and have it delete itself:
bool my_dialog::on_delete_event(GdkEventAny*)
{
delete this;
return true;
}
... note that you are probably going to want to handle key events such
as "Escape" also, and that you will have to ensure that your dialog
class instances don't outlive their data. In K-3D we have several
dialogs that use this technique to manage their own lifetimes; they all
front for data contained within a "document" class that represents an
open user document. The document class has a signal that is emitted
when the document is closed, and the dialogs connect to that signal,
deleting themselves when it is received.
Cheers,
Tim
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]