From 9d277aa2490127324d342bc926a41aa99e53ae41 Mon Sep 17 00:00:00 2001 From: hobbs Date: Wed, 12 Jan 2000 11:45:14 +0000 Subject: * library/dialog.tcl: improved handling of $default arg to allow for name of given button, as well as bounds checking --- library/dialog.tcl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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. -- cgit v0.12