in reply to Tk - intercepting alt-f4 and the like
#!perl -w use strict; use Tk; use Tk::Dialog; my $mw = MainWindow->new(); $mw->protocol('WM_DELETE_WINDOW', \&ExitApplication); $mw->bind("<Alt-F4>", \&ExitApplication); # intercept Alt-F4, too MainLoop; sub ExitApplication { # Draw dialog yes|no my $dialog = $mw->Dialog(-text => 'Do you really want to quit?', -bitmap => 'question', -title => 'Quit?', -default_button => 'Yes', -buttons => [qw/Yes No/], ); my $answer = $dialog->Show(); if ($answer =~ /y/i){ # maybe do some cleaning up and exit; } else { # continue } } # ExitApplication
Best regards,
perl -le "s==*F=e=>y~\*martinF~stronat~=>s~[^\w]~~g=>chop,print"
|
---|