Trap the window manager exit signal and redirect to your own exit routine. Cross platform. This won't trap someone closing or entering ctrl-c in the command.exe window. The best way to defend against that is to use wperl. (under windows)
Oops. zentara posted the correct answer while I was typing. Anyway; me too!
use warnings; use strict; use Tk; use Tk::DialogBox; my $mw = MainWindow->new; $mw->protocol('WM_DELETE_WINDOW' => \&myexit); MainLoop; sub myexit{ my $db = $mw->DialogBox(-title => "Are you sure you want to exit?" +, -buttons => ['OK', 'Cancel']); my $answer = $db->Show; Tk::exit if $answer eq 'OK'; }
In reply to Re: How to catch pushing the window "Exit" button in Perl/Tk?
by thundergnat
in thread How to catch pushing the window "Exit" button in Perl/Tk?
by Shumkar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |