summaryrefslogtreecommitdiffstats
path: root/library/tearoff.tcl
diff options
context:
space:
mode:
authorsbron <sbron@tclcode.com>2023-03-26 10:51:41 (GMT)
committersbron <sbron@tclcode.com>2023-03-26 10:51:41 (GMT)
commit78d9a8d03c9e9e435ad5a38a379addef0b65d636 (patch)
treed2e3def1cab9f7cfbe8c916849cb8f642acbd21c /library/tearoff.tcl
parent5cce831f67705a4be1cb95748567d83f473f6e99 (diff)
downloadtk-78d9a8d03c9e9e435ad5a38a379addef0b65d636.zip
tk-78d9a8d03c9e9e435ad5a38a379addef0b65d636.tar.gz
tk-78d9a8d03c9e9e435ad5a38a379addef0b65d636.tar.bz2
Make the clone inherit the bindtags from the original menu.
Diffstat (limited to 'library/tearoff.tcl')
-rw-r--r--library/tearoff.tcl25
1 files changed, 17 insertions, 8 deletions
diff --git a/library/tearoff.tcl b/library/tearoff.tcl
index d11b2b0..1dbe858 100644
--- a/library/tearoff.tcl
+++ b/library/tearoff.tcl
@@ -134,15 +134,24 @@ proc ::tk::MenuDup {src dst type} {
lappend cmd [lindex $option 0] [lindex $option 4]
}
eval $cmd
+
+ # Copy the meny entries, if any
+
set last [$src index last]
- if {$last eq "none" || $last < 0} {
- return
- }
- for {set i [$src cget -tearoff]} {$i <= $last} {incr i} {
- set cmd [list $dst add [$src type $i]]
- foreach option [$src entryconfigure $i] {
- lappend cmd [lindex $option 0] [lindex $option 4]
+ if {$last ne "none" && $last >= 0} {
+ for {set i [$src cget -tearoff]} {$i <= $last} {incr i} {
+ set cmd [list $dst add [$src type $i]]
+ foreach option [$src entryconfigure $i] {
+ lappend cmd [lindex $option 0] [lindex $option 4]
+ }
+ eval $cmd
}
- eval $cmd
}
+
+ # Duplicate the binding tags from the source menu, replacing src with dst
+
+ set tags [bindtags $src]
+ set x [lsearch -exact $tags $src]
+ if {$x >= 0} {lset tags $x $dst}
+ bindtags $dst $tags
}