[Gtk-sharp-list] HideOnDelete / DeleteEvent

Fredrik Nilsson jymdman@home.se
Fri, 16 Jul 2004 11:16:54 +0200


On fre, 2004-07-16 at 10:17 +0200, Sebastian Vorköper wrote:
> Hello,
> 
> I still have this problem that i can't hide a window than i click the
> delete button?!
> I connected the DeleteEventHandler with my own method, wich just calls
> the HideOnDelete() for that particular window.
> 
> I've included my testing source.
> I would appreachate if someone could just go over it and tell me what
> i'm doing wrong.
> Maybe its just the [ConnectBefore] thing?
> So far i've tried everything possible and didn't find the failure.
> 
> Thanks,
> Sebastian Vorköper
> sv@fogman.de
> 
> 
> using System;
> using GLib;
> using Gtk;
> using GtkSharp;
> 
> class window_test {
> 	public static Gtk.Window win1;
> 	public static Gtk.Window win2;
> 	public static Gtk.Button button1;
> 	public static Gtk.Button button2;
> 	
> 	public static void on_delete_button1_activate(object obj,
> DeleteEventArgs e) {
> 		Gtk.Application.Quit();
> 	}
> 	
> 	[ConnectBefore]
> 	public static void on_delete_button2_activate(object obj,
> DeleteEventArgs e) {
> 		win2.HideOnDelete();
> 	}
> 	
> 	public static void on_button1_activate(object obj, EventArgs e) {
> 		win2.ShowAll();
> 	}
> 	
> 	public static void on_button2_activate(object obj, EventArgs e) {
> 		win2.HideAll();
> 	}
> 	
> 	public static void Main() {
> 		Gtk.Application.Init();
> 		
> 		win1=new Gtk.Window("Window1");
> 		button1=new Gtk.Button("Show");
> 		button1.Clicked += new EventHandler (on_button1_activate);
> 		win1.Add(button1);
> 		win1.DeleteEvent += new
> DeleteEventHandler(on_delete_button1_activate);
> 		win1.ShowAll();
> 		
> 		win2=new Gtk.Window("Window2");
> 		button2=new Gtk.Button("Hide");
> 		button2.Clicked += new EventHandler (on_button2_activate);
> 		win2.Add(button2);
> 		win2.DeleteEvent += new
> DeleteEventHandler(on_delete_button2_activate);
> 		
> 		Gtk.Application.Run();
> 	}
> }
> 

Hi Sebastian,

This piece of code should work for you...

public static void on_delete_button2_activate(object obj,
DeleteEventArgs e) {
	win2.HideAll();
	e.RetVal = true;
}

Good Luck,

/Fredrik