diff options
author | hobbs <hobbs> | 2000-01-12 11:45:14 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2000-01-12 11:45:14 (GMT) |
commit | 9d277aa2490127324d342bc926a41aa99e53ae41 (patch) | |
tree | eac3df040a58c5e0ffa1a68f72f368b192246ddb | |
parent | 417d8566462493d0782bf312cdbbd4e301e30546 (diff) | |
download | tk-9d277aa2490127324d342bc926a41aa99e53ae41.zip tk-9d277aa2490127324d342bc926a41aa99e53ae41.tar.gz tk-9d277aa2490127324d342bc926a41aa99e53ae41.tar.bz2 |
* library/dialog.tcl: improved handling of $default arg to allow
for name of given button, as well as bounds checking
-rw-r--r-- | library/dialog.tcl | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/library/dialog.tcl b/library/dialog.tcl index 148a3e8..499526e 100644 --- a/library/dialog.tcl +++ b/library/dialog.tcl @@ -3,7 +3,7 @@ # This file defines the procedure tk_dialog, which creates a dialog # box containing a bitmap, a message, and one or more buttons. # -# RCS: @(#) $Id: dialog.tcl,v 1.6 1999/10/01 22:45:19 hobbs Exp $ +# RCS: @(#) $Id: dialog.tcl,v 1.7 2000/01/12 11:45:14 hobbs Exp $ # # Copyright (c) 1992-1993 The Regents of the University of California. # Copyright (c) 1994-1997 Sun Microsystems, Inc. @@ -32,6 +32,18 @@ proc tk_dialog {w title text bitmap default args} { global tkPriv tcl_platform + # Check that $default was properly given + if {[string is int $default]} { + if {$default >= [llength $args]} { + return -code error "default button index greater than number of\ + buttons specified for tk_dialog" + } + } elseif {[string equal {} $default]} { + set default -1 + } else { + set default [lsearch -exact $args $default] + } + # 1. Create the top-level window and divide it into top # and bottom parts. |