# checking modal dialog

proc ask {parent question} {
    global stillModal
    global answer
    
    xmQuestionDialog $parent.dialog managed \
        -messageString $question \
        -dialogStyle dialog_full_application_modal

    $parent.dialog okCallback {set stillModal 0; set answer 1}
    $parent.dialog cancelCallback {set stillModal 0; set answer 0}

    set stillModal 1
    while {$stillModal} {
        . processEvent
    }
    $parent.dialog destroyWidget
    puts stdout $answer
}

xtAppInitialize -class Program

xmPushButton .fred managed \
    -labelString "Press here for modal dialog"
.fred activateCallback "ask .fred {Confirm you are there...}; exit 0"

. realizeWidget

. mainLoop
