How to catch window kill?

Submitted by: Steve Cuzner Last Updated: 2006-09-20

How to handle the case, when the user clicks the "X" button in a windows's title bar

package myQuit; function window_quit_callback(win, code) { response("win: $win, code: $code"); local res = response("quit", "yes", "no"); if (res == 2) { return -1; }   return 0; } function session_quit_callback(code) { response("code: $code"); local res = response("quit", "yes", "no"); if (res == 2) { return -1; }   return 0; } window_set(current_window, 'quitCallback', 'myQuit::window_quit_callback'); session_add_callback('quit', 'myQuit::session_quit_callback');
 * 1) handles non-primary windows
 * 1) handles the primary window