diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-03-29 07:30:11 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-03-29 07:30:11 (GMT) |
commit | 3c3e58351a1441181863aa015487e10307e5d6de (patch) | |
tree | 3081e6ad1f8efc367bce61bcd8ee5caa9a3c65fd /library | |
parent | 2937446e0ba89de3f5f4cd81d6758999b3722193 (diff) | |
parent | 287ae817d18f64049ec3b37a0d233fec9117ed94 (diff) | |
download | tk-3c3e58351a1441181863aa015487e10307e5d6de.zip tk-3c3e58351a1441181863aa015487e10307e5d6de.tar.gz tk-3c3e58351a1441181863aa015487e10307e5d6de.tar.bz2 |
Merge "enhanced-index" branch, so this TIP can make use of indices like "end-1"
Diffstat (limited to 'library')
-rw-r--r-- | library/menu.tcl | 38 | ||||
-rw-r--r-- | library/tearoff.tcl | 2 | ||||
-rw-r--r-- | library/tk.tcl | 22 |
3 files changed, 38 insertions, 24 deletions
diff --git a/library/menu.tcl b/library/menu.tcl index a80e0a2..205410f 100644 --- a/library/menu.tcl +++ b/library/menu.tcl @@ -281,7 +281,7 @@ proc ::tk::MbPost {w {x {}} {y {}}} { set Priv(postedMb) $w set Priv(focus) [focus] - $menu activate none + $menu activate {} GenerateMenuSelect $menu update idletasks @@ -364,8 +364,8 @@ proc ::tk::MenuUnpost menu { if {[winfo class $parent] ne "Menu" || ![winfo ismapped $parent]} { break } - $parent activate none - $parent postcascade none + $parent activate {} + $parent postcascade {} GenerateMenuSelect $parent set type [$parent cget -type] if {$type eq "menubar" || $type eq "tearoff"} { @@ -488,6 +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 "" \ && $index ne $activeindex} { set mode [option get $menu clickToFocus ClickToFocus] if {[string is false $mode]} { @@ -499,7 +500,7 @@ proc ::tk::MenuMotion {menu x y state} { [after $delay "catch {$menu postcascade active}"] } else { set Priv(menuDeactivatedTimer) \ - [after $delay "catch {$menu postcascade none}"] + [after $delay "catch {$menu postcascade {}}"] } } } @@ -527,7 +528,7 @@ proc ::tk::MenuButtonDown menu { if {![winfo viewable $menu]} { return } - if {[$menu index active] eq "none"} { + if {[$menu index active] eq "none" || [$menu index active] eq ""} { if {[$menu cget -type] ne "menubar" } { set Priv(window) {} } @@ -585,7 +586,7 @@ proc ::tk::MenuButtonDown menu { proc ::tk::MenuLeave {menu rootx rooty state} { variable ::tk::Priv set Priv(window) {} - if {[$menu index active] eq "none"} { + if {[$menu index active] eq "none" || [$menu index active] eq ""} { return } if {[$menu type active] eq "cascade" \ @@ -593,7 +594,7 @@ proc ::tk::MenuLeave {menu rootx rooty state} { [$menu entrycget active -menu]} { return } - $menu activate none + $menu activate {} GenerateMenuSelect $menu } @@ -615,8 +616,8 @@ proc ::tk::MenuInvoke {w buttonRelease} { # dragged off the menu (possibly with a cascade posted) and # released. Unpost everything and quit. - $w postcascade none - $w activate none + $w postcascade {} + $w activate {} event generate $w <<MenuSelect>> MenuUnpost $w return @@ -629,7 +630,7 @@ proc ::tk::MenuInvoke {w buttonRelease} { ::tk::TearOffMenu $w MenuUnpost $w } elseif {[$w cget -type] eq "menubar"} { - $w postcascade none + $w postcascade {} set active [$w index active] set isCascade [string equal [$w type $active] "cascade"] @@ -638,7 +639,7 @@ proc ::tk::MenuInvoke {w buttonRelease} { # checkbuttons/commands/etc. on menubars if { $isCascade } { - $w activate none + $w activate {} event generate $w <<MenuSelect>> } @@ -653,7 +654,7 @@ proc ::tk::MenuInvoke {w buttonRelease} { } } else { set active [$w index active] - if {$Priv(popup) eq "" || $active ne "none"} { + if {$Priv(popup) eq "" || $active ne "none" || $active ne ""} { MenuUnpost $w } uplevel #0 [list $w invoke active] @@ -797,6 +798,7 @@ proc ::tk::MenuNextMenu {menu direction} { if {[winfo class $mb] eq "Menubutton" \ && [$mb cget -state] ne "disabled" \ && [$mb cget -menu] ne "" \ + && [[$mb cget -menu] index last] ne "" \ && [[$mb cget -menu] index last] ne "none"} { break } @@ -819,13 +821,13 @@ proc ::tk::MenuNextMenu {menu direction} { # -1 means go to the next higher entry. proc ::tk::MenuNextEntry {menu count} { - if {[$menu index last] eq "none"} { + if {[$menu index last] eq "none" || [$menu index last] eq ""} { return } set length [expr {[$menu index last]+1}] set quitAfter $length set active [$menu index active] - if {$active eq "none"} { + if {$active eq "none" || $active eq "none"} { set i 0 } else { set i [expr {$active + $count}] @@ -1026,7 +1028,7 @@ proc ::tk::TraverseWithinMenu {w char} { } set char [string tolower $char] set last [$w index last] - if {$last eq "none"} { + if {$last eq "none" || $last eq ""} { return } for {set i 0} {$i <= $last} {incr i} { @@ -1068,11 +1070,11 @@ proc ::tk::MenuFirstEntry menu { return } tk_menuSetFocus $menu - if {[$menu index active] ne "none"} { + if {[$menu index active] ne "none" || [$menu index active] ne ""} { return } set last [$menu index last] - if {$last eq "none"} { + if {$last eq "none" || $last eq ""} { return } for {set i 0} {$i <= $last} {incr i} { @@ -1114,7 +1116,7 @@ proc ::tk::MenuFindName {menu s} { return $i } set last [$menu index last] - if {$last eq "none"} { + if {$last eq "none" || $last eq ""} { return } for {set i 0} {$i <= $last} {incr i} { diff --git a/library/tearoff.tcl b/library/tearoff.tcl index f69a988..605074f 100644 --- a/library/tearoff.tcl +++ b/library/tearoff.tcl @@ -135,7 +135,7 @@ proc ::tk::MenuDup {src dst type} { } eval $cmd set last [$src index last] - if {$last eq "none"} { + if {$last eq "none" || $last eq ""} { return } for {set i [$src cget -tearoff]} {$i <= $last} {incr i} { diff --git a/library/tk.tcl b/library/tk.tcl index da388bd..5edafc2 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -703,17 +703,29 @@ if {[tk windowingsystem] eq "aqua"} { if {[info commands ::tk::endOfWord] eq ""} { proc ::tk::endOfWord {str start {locale {}}} { - return [tcl_endOfWord $str $start] + set start [tcl_endOfWord $str $start] + if {$start < 0} { + set start "" + } + return $start } } if {[info commands ::tk::startOfNextWord] eq ""} { proc ::tk::startOfNextWord {str start {locale {}}} { - return [tcl_startOfNextWord $str $start] + set start [tcl_startOfNextWord $str $start] + if {$start < 0} { + set start "" + } + return $start } } if {[info commands ::tk::startOfPreviousWord] eq ""} { proc ::tk::startOfPreviousWord {str start {locale {}}} { - return [tcl_startOfPreviousWord $str $start] + set start [tcl_startOfPreviousWord $str $start] + if {$start < 0} { + set start "" + } + return $start } } if {[info commands ::tk::endOfCluster] eq ""} { @@ -721,7 +733,7 @@ if {[info commands ::tk::endOfCluster] eq ""} { if {$start eq "end"} { return [string length $str] } elseif {$start >= [string length $str]} { - return -1 + return "" } if {[string length [string index $str $start]] > 1} { set start [expr {$start+1}] @@ -741,7 +753,7 @@ if {[info commands ::tk::startOfCluster] eq ""} { set start [expr {$start-1}] } if {$start < 0} { - return -1 + return "" } return $start } |