| Ticket UUID: | 44eff2112d5687a5a392bbe2bf6064125879995d | |||
| Title: | bind scripts: documentation on return codes. | |||
| Type: | Bug | Version: | 8.6.1 | |
| Submitter: | anonymous | Created on: | 2016-06-23 18:08:10 | |
| Subsystem: | 01. Bindings | Assigned To: | nobody | |
| Priority: | 5 Medium | Severity: | Important | |
| Status: | Closed | Last Modified: | 2026-10-22 17:22:36 | |
| Resolution: | Duplicate | Closed By: | serhiy.storchaka | |
| Closed on: | 2026-09-25 08:31:15 | |||
| Description: |
The bind documentation states:
"The continue and break commands may be used inside a binding script to control the processing of matching scripts. If continue is invoked, then the current binding script is terminated but Tk will continue processing binding scripts associated with other tag's. If the break command is invoked within a binding script, then that script terminates and no other scripts will be invoked for the event."
I was expecting bind to continue with the next bound script, but it continues with the next bound tag. I guess the assumption was that noone would be binding
to duplicate tags.
However, if the script uses {return -code ok}, bind will continue with the
next bound script using the same tag.
The {return -code ok} should be documented, and some better clarification of how bindings interact with the same tag name and {continue} would be nice.
In the following program the following bindings are active.
All bindings are prefixed with the {+}, and in each case the binding
is set twice.
page-up : runs a script that returns -code ok
page-down : runs a script that returns -code continue
up-arrow : uses {continue} directly inside the bind script
#!/usr/bin/tclsh
package require Tk
proc tbind { val w1 w2 } {
lassign [winfo pointerxy $w2] x y
set wz [winfo containing $x $y]
puts "val:$val w1:$w1 w2:$w2 wz:$wz"
if { $w1 == $wz } {
puts "got key"
} else {
puts "wrong window"
}
if { $val } {
return -code ok
} else {
return -code continue
}
}
frame .a -width 100 -height 200 -background cyan
frame .b -width 100 -height 200 -background green
pack .a .b -in . -side left -expand true -fill both
bind all <Prior> +[list tbind 1 .a %W]
bind all <Prior> +[list tbind 1 .b %W]
bind all <Next> +[list tbind 0 .a %W]
bind all <Next> +[list tbind 0 .b %W]
bind all <<PrevLine>> "+tbind 1 .a %W ; continue"
bind all <<PrevLine>> "+tbind 1 .b %W ; continue"
| |||
| User Comments: |
serhiy.storchaka added on 2026-09-25 08:31:15:
Duplicate of [d0c55bd78a], fixed in 8.6.8 by [c0dbd605a1]: bind.n documents continue, break and ok in binding scripts. Closing. | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki