proc mkdialog {label back retval} {
global dialtext
eval global $retval
toplevel .dial

label .dial.label -text "$label: " -font fixed
entry .dial.entry -textvariable dialtext -font fixed
pack .dial.label .dial.entry -side left

focus .dial

proc unfocus {} "focus $back"

# proc nailret {} "global $retval dialtext; eval set $retval $dialtext"
proc nailret {} \
[ concat "global" $retval "dialtext;  set " $retval "\$dialtext" ]

bind .dial.entry <Any-Leave> { unfocus }
bind .dial.entry <Any-Enter> { focus .dial.entry }
bind .dial.entry <Return> { unfocus; destroy .dial; nailret }
}

proc callbackdialog {label back callback} {
    global dialtext
    toplevel .dial
    
    label .dial.label -text "$label: " -font fixed
    entry .dial.entry -textvariable dialtext -font fixed
    pack .dial.label .dial.entry -side left
    
    focus .dial

    proc unfocus {} "focus $back"
    
    proc nailret {} "global dialtext; eval $callback \$dialtext"
    
    bind .dial.entry <Any-Leave> { unfocus }
    bind .dial.entry <Any-Enter> { focus .dial.entry }
    bind .dial.entry <Return> { unfocus; destroy .dial; nailret }
}


