Re: FW: Tk::DialogBox bug

Slaven Rezic <[email protected]>
Newsgroups gmane.comp.lang.perl.tk
Message-ID <[email protected]>
"Benjamin Fitch" <[email protected]> writes:

> Thought that I should copy you (after the fact), as I saw some comments from
> you on the Web that are related to this issue.
> 

Attached is a diff which introduces a new option named -cancel_button
to specify the action on closing the dialog.



> Thanks!
> 
> -----Original Message-----
> From: Benjamin Fitch [mailto:[email protected]] 
> Sent: Sunday, June 12, 2005 12:02 PM
> To: '[email protected]'
> Subject: Tk::DialogBox bug
> 
> 
> An end user concluded that a Perl/Tk application was broken because the
> close button (X) in the upper-right corner of a multiple-button DialogBox
> doesn't work, and neither does ALT+F4 (this is ActivePerl 5.8.6 on Windows
> XP) nor <Escape>.  (I can bind <Escape>, but I can't fix the close button or
> ALT+F4.)
> 
> The close button as well as ALT+F4 must work, or it looks to the user that
> the application is broken and unprofessional.  There needs to be an option
> that specifies which DialogBox button to return when the user clicks the
> close button.  Then <Escape> and ALT+F4 must return the same thing.  It's
> certain that no one would object to this necessary option.  (Alternatively,
> when the user chooses to dismiss the DialogBox without clicking any of the
> provided buttons, the return value could be "".)
> 
> If I can't make a DialogBox that doesn't appear broken, I'll have to drop
> Perl and learn REALbasic.  :-)
> 
> Thank you for your time,
> Benjamin Fitch
> 
> 
> 

-- 
Slaven Rezic - slaven <at> rezic <dot> de

    tkrevdiff - graphical display of diffs between revisions (RCS, CVS or SVN)
    http://ptktools.sourceforge.net/#tkrevdiff
dialogbox-with-cancelbutton.diff (text/x-patch, 875 B)
--- /usr/local/src/Tk-804.027/Tixish/DialogBox.pm	Thu Dec 11 21:21:35 2003
+++ /tmp/DialogBox.pm	Tue Jun 14 01:51:31 2005
@@ -30,7 +30,10 @@
     if (@$buttons == 1) {
 	$cw->protocol('WM_DELETE_WINDOW' => sub { $cw->{'default_button'}->invoke });
     } else {
-	$cw->protocol('WM_DELETE_WINDOW' => sub {});
+	$cw->protocol('WM_DELETE_WINDOW' => sub {
+			  my $cancel_button = $cw->cget('-cancel_button');
+			  $cw->Subwidget("B_" . $cancel_button)->invoke if $cancel_button;
+		      });
     }
 
     # create the two frames
@@ -72,6 +75,7 @@
                      -background => ['DESCENDANTS', 'background','Background',  undef],
 		     -focus	 => ['PASSIVE', undef, undef, undef],
 		     -showcommand => ['CALLBACK', undef, undef, undef],
+		     -cancel_button => ['PASSIVE', undef, undef, undef],
                     );
     $cw->Delegates('Construct',$top);
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.