summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/busy.n17
-rw-r--r--generic/tkBusy.c22
-rw-r--r--tests/busy.test64
3 files changed, 84 insertions, 19 deletions
diff --git a/doc/busy.n b/doc/busy.n
index ab2fd8a..6a3e6b6 100644
--- a/doc/busy.n
+++ b/doc/busy.n
@@ -32,6 +32,8 @@ busy \- confine pointer events to a window sub-tree
.SH SYNOPSIS
\fBtk busy\fR \fIwindow \fR?\fIoptions\fR?
.sp
+\fBtk busy busywindow \fIwindow\fR
+.sp
\fBtk busy hold\fR \fIwindow \fR?\fIoptions\fR?
.sp
\fBtk busy configure \fIwindow\fR ?\fIoption value\fR?...
@@ -128,6 +130,11 @@ The following operations are available for the \fBtk busy\fR command:
.
Shortcut for \fBtk busy hold\fR command.
.TP
+\fBtk busy busywindow \fIwindow\fR
+.
+Returns the pathname of the busy (transparent) window created by the
+\fBtk busy hold\fR command for \fIwindow\fR.
+.TP
\fBtk busy hold \fIwindow\fR ?\fIoption value\fR?...
.
Makes the specified \fIwindow\fR (and its descendants in the Tk window
@@ -137,6 +144,7 @@ window is mapped the next time idle tasks are processed, and the specified
window and its descendants will be blocked from user interactions. Normally
\fBupdate\fR should be called immediately afterward to insure that the hold
operation is in effect before the application starts its processing. The
+command returns the pathname of the busy (transparent) window created. The
following configuration options are valid:
.RS
.TP
@@ -233,6 +241,15 @@ example, the pathname of the busy window is
\fBtk busy\fR hold .
bind ._Busy <Enter> { ... }
.CE
+.PP
+Note that these implementation details can be entirely ignored by using the
+return value of the \fBtk busy\fR command, or alternatively the
+\fBtk busy busywindow\fR command as follows:
+.PP
+.CS
+\fBtk busy\fR hold .frame.canvas
+bind [\fBtk busy\fR busywindow .frame.canvas] <Enter> { ... }
+.CE
.SS "ENTER/LEAVE EVENTS"
.PP
Mapping and unmapping busy windows generates Enter/Leave events for all
diff --git a/generic/tkBusy.c b/generic/tkBusy.c
index 514465a..b418421 100644
--- a/generic/tkBusy.c
+++ b/generic/tkBusy.c
@@ -761,6 +761,9 @@ HoldBusy(
} else {
TkpHideBusyWindow(busyPtr);
}
+ if (result == TCL_OK) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_PathName(busyPtr->tkBusy), -1));
+ }
return result;
}
@@ -794,11 +797,12 @@ Tk_BusyObjCmd(
Tcl_Obj *objPtr;
int index, result = TCL_OK;
static const char *const optionStrings[] = {
- "cget", "configure", "current", "forget", "hold", "status", NULL
+ "busywindow", "cget", "configure", "current", "forget", "hold",
+ "status", NULL
};
enum options {
- BUSY_CGET, BUSY_CONFIGURE, BUSY_CURRENT, BUSY_FORGET, BUSY_HOLD,
- BUSY_STATUS
+ BUSY_BUSYWINDOW, BUSY_CGET, BUSY_CONFIGURE, BUSY_CURRENT, BUSY_FORGET,
+ BUSY_HOLD, BUSY_STATUS
};
if (objc < 2) {
@@ -823,6 +827,18 @@ Tk_BusyObjCmd(
return TCL_ERROR;
}
switch ((enum options) index) {
+ case BUSY_BUSYWINDOW:
+ if (objc != 3) {
+ Tcl_WrongNumArgs(interp, 2, objv, "window");
+ return TCL_ERROR;
+ }
+ busyPtr = GetBusy(interp, busyTablePtr, objv[2]);
+ if (busyPtr == NULL) {
+ return TCL_ERROR;
+ }
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_PathName(busyPtr->tkBusy), -1));
+ return TCL_OK;
+
case BUSY_CGET:
if (objc != 4) {
Tcl_WrongNumArgs(interp, 2, objv, "window option");
diff --git a/tests/busy.test b/tests/busy.test
index 304c2eb..6f22b85 100644
--- a/tests/busy.test
+++ b/tests/busy.test
@@ -23,53 +23,59 @@ test busy-2.1 {tk busy hold} -returnCodes error -body {
tk busy hold
} -result {wrong # args: should be "tk busy hold window ?option value ...?"}
test busy-2.2 {tk busy hold root window} -body {
- tk busy hold .
+ set res [tk busy hold .]
update
+ set res
} -cleanup {
tk busy forget .
-} -result {}
+} -result {._Busy}
test busy-2.3 {tk busy hold root window with shortcut} -body {
- tk busy .
+ set res [tk busy .]
update
+ set res
} -cleanup {
tk busy forget .
-} -result {}
+} -result {._Busy}
test busy-2.4 {tk busy hold nested window} -setup {
pack [frame .f]
} -body {
- tk busy hold .f
+ set res [tk busy hold .f]
update
+ set res
} -cleanup {
tk busy forget .f
destroy .f
-} -result {}
+} -result {.f_Busy}
test busy-2.5 {tk busy hold nested window with shortcut} -setup {
pack [frame .f]
} -body {
- tk busy .f
+ set res [tk busy .f]
update
+ set res
} -cleanup {
tk busy forget .f
destroy .f
-} -result {}
+} -result {.f_Busy}
test busy-2.6 {tk busy hold toplevel window} -setup {
toplevel .f
} -body {
- tk busy hold .f
+ set res [tk busy hold .f]
update
+ set res
} -cleanup {
tk busy forget .f
destroy .f
-} -result {}
+} -result {.f._Busy}
test busy-2.7 {tk busy hold toplevel window with shortcut} -setup {
toplevel .f
} -body {
- tk busy .f
+ set res [tk busy .f]
update
+ set res
} -cleanup {
tk busy forget .f
destroy .f
-} -result {}
+} -result {.f._Busy}
test busy-2.8 {tk busy hold non existing window} -body {
tk busy hold .f
update
@@ -79,17 +85,19 @@ test busy-2.9 {tk busy hold (shortcut) non existing window} -body {
update
} -returnCodes {error} -result {bad window path name ".f"}
test busy-2.10 {tk busy hold root window with cursor} -body {
- tk busy hold . -cursor arrow
+ set res [tk busy hold . -cursor arrow]
update
+ set res
} -cleanup {
tk busy forget .
-} -result {}
+} -result {._Busy}
test busy-2.11 {tk busy hold (shortcut) root window, cursor} -body {
- tk busy . -cursor arrow
+ set res [tk busy . -cursor arrow]
update
+ set res
} -cleanup {
tk busy forget .
-} -result {}
+} -result {._Busy}
test busy-2.12 {tk busy hold root window, invalid cursor} -body {
tk busy hold . -cursor nonExistingCursor
update
@@ -473,5 +481,29 @@ test busy-7.9 {tk busy current 2 busy with non matching filter after forget} -se
destroy .f1 .f2
} -result {}
+test busy-8.1 {tk busy busywindow with a busy toplevel} -body {
+ toplevel .top
+ tk busy .top
+ tk busy busywindow .top
+} -cleanup {
+ tk busy forget .top
+ destroy .top
+} -result {.top._Busy}
+test busy-8.2 {tk busy busywindow with a busy widget} -body {
+ pack [frame .f]
+ tk busy .f
+ tk busy busywindow .f
+} -cleanup {
+ tk busy forget .f
+ destroy .f
+} -result {.f_Busy}
+test busy-8.3 {tk busy busywindow with a nonexisting widget} -body {
+ tk busy .
+ tk busy busywindow .nonExistingWidget
+} -cleanup {
+ tk busy forget .
+} -returnCodes error -result {bad window path name ".nonExistingWidget"}
+
+
::tcltest::cleanupTests
return