I'm playing around a little bit again with Tk, and got the following problem:
If anybody just presses at the X at the upper right corner of the window or Alt+F4 (i mostly work under Win2k), the Window closes and the program finishes.
With something like the code above, I could at least do some cleanup before quitting.#!perl -w use strict; use Tk; my $mw = MainWindow->new(); $mw->OnDestroy( \&ExitApplication ); MainLoop; sub ExitApplication { print ("Exiting\n"); # do some cleanup }
What I'm looking for: if somebody presses the X at the top right corner of the window or Alt-F4, I want a MsgBox to pop up and ask "Do you really want to quit (Yes/No)", and if the user presses the Button for "No", the program should continue running. With OnDestroy, I only know a way to quit, but not to go on.
Best regards and thanx in advance,
perl -le "s==*F=e=>y~\*martinF~stronat~=>s~[^\w]~~g=>chop,print"
In reply to Tk - intercepting alt-f4 and the like by strat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |