Tk Source Code

Artifact [9187f7c7]
Login

Artifact 9187f7c79d2c2dfeff5d5017f7ae24cc56060d6e:

Attachment "dialog_demo.tcl" to ticket [3414089f] added by cjmcdonald 2011-09-26 23:18:01.
# This script demonstrates a grab interaction problem on Windows-XP.
# It creates a pop-up transient dialog, and uses grab to make it
# modal, waiting until the user clicks OK before interaction with
# the rest of the application continues.  For demonstration the
# script is kept very simple.
#
# Whilst the pop-up dialog is visible, click right on some empty
# space in the Windows-XP taskbar and select "Show Desktop".  This
# minimises all open application windows.  It is then impossible for
# the user to restore the minimised Tk application window.  The
# application has to be killed using the task manager.
#
# This problem appears to be another unintended consequence of bug
# fix 1847002 (also see #2896605).  Using wish 8.5.6 works as
# expected, after the "Show Desktop" the user can click on the
# minimised application window in the task bar in order to restore
# it.


button .b -text "Modal Dialog..." -command invoke_dialog
grid .b -padx 5c -pady 5c


proc invoke_dialog {} {

    # Create a simple pop-up dialog.

    destroy .d

    toplevel .d
    wm transient .d .

    label .d.l -text "Name:"
    entry .d.e
    grid .d.l .d.e

    button .d.b -text OK -command {set entry_done 1}
    grid .d.b -columnspan 2

    # Use grab to make the dialog modal, waiting for
    # the user to click OK.

    grab .d

    vwait entry_done

    grab release .d
    destroy .d
}