summaryrefslogtreecommitdiffstats
path: root/library/demos
diff options
context:
space:
mode:
authorculler <culler>2019-01-08 22:53:29 (GMT)
committerculler <culler>2019-01-08 22:53:29 (GMT)
commit4461111c77163d5fad79721108a7d52f83ed3e49 (patch)
tree8cd1abf09c4de523ab69edcbecc9d66f3b21ef75 /library/demos
parent1615a89ab7456071e1091399dbe169c8f1d7d757 (diff)
downloadtk-4461111c77163d5fad79721108a7d52f83ed3e49.zip
tk-4461111c77163d5fad79721108a7d52f83ed3e49.tar.gz
tk-4461111c77163d5fad79721108a7d52f83ed3e49.tar.bz2
Update the demos to give a more complete explanation of local and global grabs.
Diffstat (limited to 'library/demos')
-rw-r--r--library/demos/dialog1.tcl14
-rw-r--r--library/demos/dialog2.tcl3
2 files changed, 15 insertions, 2 deletions
diff --git a/library/demos/dialog1.tcl b/library/demos/dialog1.tcl
index 5c572be..976e955 100644
--- a/library/demos/dialog1.tcl
+++ b/library/demos/dialog1.tcl
@@ -2,8 +2,16 @@
#
# This demonstration script creates a dialog box with a local grab.
+interp create slave
+load {} Tk slave
+slave eval {
+ wm title . slave
+ wm geometry . +700+30
+ pack [text .t -width 30 -height 10]
+}
+
after idle {.dialog1.msg configure -wraplength 4i}
-set i [tk_dialog .dialog1 "Dialog with local grab" {This is a modal dialog box. It uses Tk's "grab" command to create a "local grab" on the dialog box. The grab prevents any pointer-related events from getting to any other windows in the application until you have answered the dialog by invoking one of the buttons below. However, you can still interact with other applications.} \
+set i [tk_dialog .dialog1 "Dialog with local grab" {This is a modal dialog box. It uses Tk's "grab" command to create a "local grab" on the dialog box. The grab prevents any mouse or keyboard events from getting to any other windows in the application until you have answered the dialog by invoking one of the buttons below. However, you can still interact with other applications. For example, you should be able to edit text in the window named "slave" which was created by a slave interpreter.} \
info 0 OK Cancel {Show Code}]
switch $i {
@@ -11,3 +19,7 @@ switch $i {
1 {puts "You pressed Cancel"}
2 {showCode .dialog1}
}
+
+if {[interp exists slave]} {
+ interp delete slave
+}
diff --git a/library/demos/dialog2.tcl b/library/demos/dialog2.tcl
index 2f45da8..6ae27a8 100644
--- a/library/demos/dialog2.tcl
+++ b/library/demos/dialog2.tcl
@@ -8,7 +8,8 @@ after idle {
after 100 {
grab -global .dialog2
}
-set i [tk_dialog .dialog2 "Dialog with global grab" {This dialog box uses a global grab, so it prevents you from interacting with anything on your display until you invoke one of the buttons below. Global grabs are almost always a bad idea; don't use them unless you're truly desperate.} warning 0 OK Cancel {Show Code}]
+set i [tk_dialog .dialog2 "Dialog with global grab" {This dialog box uses a global grab. If you are using an X11 window manager you will be prevented from interacting with anything on your display until you invoke one of the buttons below. This is almost always a bad idea; don't use global grabs with X11 unless you're truly desperate. On macOS systems you will not be able to interact with any window belonging to this process, but interaction with other macOS Applications will still be possible.}\
+warning 0 OK Cancel {Show Code}]
switch $i {
0 {puts "You pressed OK"}