Changeset 1741 for trunk/gui


Ignore:
Timestamp:
May 25, 2010 3:25:00 PM (14 years ago)
Author:
dkearney
Message:

fix choicehandler to choose the first option in the list if there is no default value given, and check for value tags in options before using the label as the value of the choice.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/apps/simsim.in

    r1612 r1741  
    204204    } else {
    205205        set optList [$child children -as object -type option]
     206        set optLib ""
    206207        set value ""
    207         if {"random" == $valType} {
    208             set optIdx [expr {int(rand()*[llength $optList])}]
    209             set optLib [lindex $optList $optIdx]
    210             set value [$optLib get value]
    211         } elseif {"default" == $valType} {
    212             set defaultVal [$child get default]
    213             foreach optLib $optList {
    214                 set label [$optLib get about.label]
    215                 set valTag [$optLib get value]
    216                 if {($defaultVal == $label) || ($defaultVal == $valTag)} {
    217                     set value $valTag
    218                     break
     208        if {[llength $optList] > 0} {
     209            if {"random" == $valType} {
     210                set optIdx [expr {int(rand()*[llength $optList])}]
     211                set optLib [lindex $optList $optIdx]
     212                set value [$optLib get value]
     213            } elseif {"default" == $valType} {
     214                set defaultVal [$child get default]
     215                foreach optLib $optList {
     216                    set label [$optLib get about.label]
     217                    set valTag [$optLib get value]
     218                    if {($defaultVal == $label) || ($defaultVal == $valTag)} {
     219                        set value $valTag
     220                        break
     221                    }
    219222                }
    220223            }
    221         }
    222 
    223         if {"" == $value} {
    224             set value [$optLib get about.label]
     224
     225            if {"" == $value} {
     226                set optLib [lindex $optList 0]
     227                set value [$optLib get value]
     228                if {"" == $value} {
     229                    set value [$optLib get about.label]
     230                }
     231            }
    225232        }
    226233        $child put "current" $value
Note: See TracChangeset for help on using the changeset viewer.