Sign up

How to hide a window instead of deleting it on close?

Hello guys,

currently trying to set my first basic GUI for a program of mine. I have no trouble managing callbacks like addOnShow(...), but I haven't been able to find the gtkD how-to to hide a window when the user presses the close (X) button instead of deleting it.

Could someone help me out?

Re: How to hide a window instead of deleting it on close?

On 07/02/2016 10:37 PM, Dechcaudron wrote:

Hello guys,

currently trying to set my first basic GUI for a program of mine. I have no trouble managing callbacks like addOnShow(...), but I haven't been able to find the gtkD how-to to hide a window when the user presses the close (X) button instead of deleting it.

Could someone help me out?

For windows you could set an on delete handler that hides the window,
return true so it stops processing other handlers, so the window doesn't
get destroyed anyway.

yourWindow.addOnDelete(bool delegate(Event e, Widget w) {
	w.hide();
	return true;
});

Re: How to hide a window instead of deleting it on close?

On Sun, 3 Jul 2016 09:32:32 +0200, Mike Wey wrote:

For windows you could set an on delete handler that hides the window,
return true so it stops processing other handlers, so the window doesn't
get destroyed anyway.

yourWindow.addOnDelete(bool delegate(Event e, Widget w) {
	w.hide();
	return true;
});

That did it. Thanks a bunch!