kranthi has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I am facing an issue with closing the Dialogbox. When we close the Dialog box using X button that appears on the topmost corner of the dialog, then it selects the value of the default_button and continues further. I dont want this to happen. The task should halt at this point.
After searching for the same, I came to know that this is a bug is Perl/Tk. I also tried to capture this with Ondestroy and
$dialog->Subwidget('Cancel')->Invoke(); method but it didn't work.
Can any one let me know how to handle this issue. Here is the code:
my $dialog = $Global::mw->Dialog(-title => 'Status', -text => "Do you wish to continue", -default_button => 'Ok', -buttons => ['Ok', 'Cancel'], -font => ['Arial',10 ] )->Show(); $dialog->Subwidget('Cancel')->Invoke();

Replies are listed 'Best First'.
Re: Handling Dialogbox
by zentara (Cardinal) on Nov 03, 2008 at 14:13 UTC
    Please show full snippets that work, or demonstrate your problem. All the dialogs I have tested, have their X button disabled automatically. You might try
    $dialog->protocol('WM_DELETE_WINDOW' => sub { print "nope\n"; });
    that
    my $dialog = $Global::mw->Dialog()
    looks odd, and may be interfering with the window manager controls.

    I'm not really a human, but I play one on earth Remember How Lucky You Are
      Hi zentara, Thank you for your time. I have gone through the CPAN Tk::DialogBox and found the option -cancel_button
      which is invoked when the user closes the DialogBox using the window manager's close button. It worked perfectly.
      Thanks once again.