summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2023-12-12 13:03:30 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2023-12-12 13:03:30 (GMT)
commit41c09d4eae90dcdf6a7e1e4a026ba320356e500a (patch)
treeb9ed29964c2c941274ff53c67944b24a8f5f7c2a /library
parente76d34cdf6a82f06d8340580557e203f3b3086ef (diff)
downloadtk-41c09d4eae90dcdf6a7e1e4a026ba320356e500a.zip
tk-41c09d4eae90dcdf6a7e1e4a026ba320356e500a.tar.gz
tk-41c09d4eae90dcdf6a7e1e4a026ba320356e500a.tar.bz2
Backport some clean-up from 8.7
Diffstat (limited to 'library')
-rw-r--r--library/menu.tcl28
-rw-r--r--library/ttk/notebook.tcl8
2 files changed, 20 insertions, 16 deletions
diff --git a/library/menu.tcl b/library/menu.tcl
index deca485..3de7cc5 100644
--- a/library/menu.tcl
+++ b/library/menu.tcl
@@ -88,7 +88,7 @@ bind Menubutton <Enter> {
bind Menubutton <Leave> {
tk::MbLeave %W
}
-bind Menubutton <1> {
+bind Menubutton <Button-1> {
if {$tk::Priv(inMenubutton) ne ""} {
tk::MbPost $tk::Priv(inMenubutton) %X %Y
}
@@ -475,7 +475,7 @@ proc ::tk::MbButtonUp w {
proc ::tk::MenuMotion {menu x y state} {
variable ::tk::Priv
if {$menu eq $Priv(window)} {
- set active [$menu index active]
+ set activeindex [$menu index active]
if {[$menu cget -type] eq "menubar"} {
if {[info exists Priv(focus)] && $menu ne $Priv(focus)} {
$menu activate @$x,$y
@@ -488,7 +488,7 @@ proc ::tk::MenuMotion {menu x y state} {
set index [$menu index @$x,$y]
if {[info exists Priv(menuActivated)] \
&& $index ne "none" \
- && $index ne $active} {
+ && $index ne $activeindex} {
set mode [option get $menu clickToFocus ClickToFocus]
if {[string is false $mode]} {
set delay [expr {[$menu cget -type] eq "menubar" ? 0 : 50}]
@@ -496,10 +496,12 @@ proc ::tk::MenuMotion {menu x y state} {
# Catch these postcascade commands since the menu could be
# destroyed before they run.
set Priv(menuActivatedTimer) \
- [after $delay "catch {$menu postcascade active}"]
+ [after $delay [list catch [list \
+ $menu postcascade active]]]
} else {
set Priv(menuDeactivatedTimer) \
- [after $delay "catch {$menu postcascade none}"]
+ [after $delay [list catch [list
+ $menu postcascade {}]]]
}
}
}
@@ -819,10 +821,11 @@ proc ::tk::MenuNextMenu {menu direction} {
# -1 means go to the next higher entry.
proc ::tk::MenuNextEntry {menu count} {
- if {[$menu index last] eq "none"} {
+ set last [$menu index last]
+ if {$last eq "none"} {
return
}
- set length [expr {[$menu index last]+1}]
+ set length [expr {$last+1}]
set quitAfter $length
set active [$menu index active]
if {$active eq "none"} {
@@ -903,13 +906,12 @@ proc ::tk::MenuFind {w char} {
}
set last [$child index last]
for {set i [$child cget -tearoff]} {$i <= $last} {incr i} {
- if {[$child type $i] eq "separator"} {
+ if {([$child type $i] eq "separator") || ([$child entrycget $i -state] eq "disabled")} {
continue
}
- set char2 [string index [$child entrycget $i -label] \
- [$child entrycget $i -underline]]
- if {$char eq [string tolower $char2] || $char eq ""} {
- if {[$child entrycget $i -state] ne "disabled"} {
+ set underline [$child entrycget $i -underline]
+ if {$underline >= 0} {
+ if {$char eq [string tolower [string index [$child entrycget $i -label] $underline]]} {
return $child
}
}
@@ -941,7 +943,7 @@ proc ::tk::MenuFind {w char} {
}
}
}
- return ""
+ return {}
}
# ::tk::TraverseToMenu --
diff --git a/library/ttk/notebook.tcl b/library/ttk/notebook.tcl
index 518c6f5..c5e6d94 100644
--- a/library/ttk/notebook.tcl
+++ b/library/ttk/notebook.tcl
@@ -81,9 +81,11 @@ proc ttk::notebook::MnemonicTab {nb key} {
foreach tab [$nb tabs] {
set label [$nb tab $tab -text]
set underline [$nb tab $tab -underline]
- set mnemonic [string toupper [string index $label $underline]]
- if {$mnemonic ne "" && $mnemonic eq $key} {
- return $tab
+ if {$underline >= 0} {
+ set mnemonic [string toupper [string index $label $underline]]
+ if {$mnemonic ne "" && $mnemonic eq $key} {
+ return $tab
+ }
}
}
return ""