Re: Gtk::Dialog::on_delete_event() is never called
- From: Tobias Eberle <tobias eberle gmx de>
- To: Murray Cumming <murrayc murrayc com>
- Cc: gtkmm-list gnome org
- Subject: Re: Gtk::Dialog::on_delete_event() is never called
- Date: Mon, 01 Aug 2005 13:43:35 +0200
Hallo,
> > I want to prevent that the user can close a dialog (derived from
> > Gtk::Dialog) by clicking on the X. I tried to override
> > on_delete_event():
> This shold work. Try a simple test case. It certainly works with
> Gtk::Window. You might also investigate on_response().
It works with Gtk::Window, but it doesn't with Gtk::Dialog. Try the
following test program:
#include <gtkmm.h>
#include <iostream>
class CMyDialog : public Gtk::Dialog
{
public:
CMyDialog() : Gtk::Dialog("dialog", true)
{
add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
show_all_children();
}
protected:
bool on_delete_event(GdkEventAny *)
{
std::cout << "this doesn't work" << std::endl;
return true;
}
};
class CMyWindow : public Gtk::Window
{
public:
CMyWindow() : Gtk::Window()
{
pwButton = Gtk::manage(new Gtk::Button("open dialog"));
pwButton->signal_clicked().connect(
sigc::mem_fun(*this, &CMyWindow::on_button_clicked));
add(*pwButton);
show_all_children();
}
protected:
Gtk::Button *pwButton;
void on_button_clicked()
{
CMyDialog oMyDialog;
oMyDialog.run();
}
bool on_delete_event(GdkEventAny *pEvent)
{
std::cout << "this works" << std::endl;
return Gtk::Window::on_delete_event(pEvent);
}
};
int main(int argc, char **argv)
{
Gtk::Main m(argc, argv);
CMyWindow oMyWindow;
Gtk::Main::run(oMyWindow);
return 0;
}
Bye, Tobias
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]