summaryrefslogtreecommitdiffstats
path: root/library/menu.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'library/menu.tcl')
-rw-r--r--library/menu.tcl280
1 files changed, 141 insertions, 139 deletions
diff --git a/library/menu.tcl b/library/menu.tcl
index 6c4e153..2c2c751 100644
--- a/library/menu.tcl
+++ b/library/menu.tcl
@@ -4,7 +4,7 @@
# It also implements keyboard traversal of menus and implements a few
# other utility procedures related to menus.
#
-# RCS: @(#) $Id: menu.tcl,v 1.7 1999/07/22 16:31:48 redman Exp $
+# RCS: @(#) $Id: menu.tcl,v 1.8 1999/09/02 17:02:52 hobbs Exp $
#
# Copyright (c) 1992-1994 The Regents of the University of California.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
@@ -119,9 +119,9 @@ bind Menu <FocusIn> {}
bind Menu <Enter> {
set tkPriv(window) %W
- if {![string compare [%W cget -type] "tearoff"]} {
- if {[string compare "%m" "NotifyUngrab"]} {
- if {![string compare $tcl_platform(platform) "unix"]} {
+ if {[string equal [%W cget -type] "tearoff"]} {
+ if {[string compare "%m" "NotifyUngrab"]} {
+ if {[string equal $tcl_platform(platform) "unix"]} {
tk_menuSetFocus %W
}
}
@@ -169,7 +169,7 @@ bind Menu <KeyPress> {
# The following bindings apply to all windows, and are used to
# implement keyboard menu traversal.
-if {![string compare $tcl_platform(platform) "unix"]} {
+if {[string equal $tcl_platform(platform) "unix"]} {
bind all <Alt-KeyPress> {
tkTraverseToMenu %W %A
}
@@ -222,7 +222,7 @@ proc tkMbLeave w {
if {![winfo exists $w]} {
return
}
- if {![string compare [$w cget -state] "active"]} {
+ if {[string equal [$w cget -state] "active"]} {
$w configure -state normal
}
}
@@ -243,16 +243,16 @@ proc tkMbPost {w {x {}} {y {}}} {
global tkPriv errorInfo
global tcl_platform
- if {![string compare [$w cget -state] "disabled"] ||
- ![string compare $w $tkPriv(postedMb)]} {
+ if {[string equal [$w cget -state] "disabled"] || \
+ [string equal $w $tkPriv(postedMb)]} {
return
}
set menu [$w cget -menu]
- if {![string compare $menu ""]} {
+ if {[string equal $menu ""]} {
return
}
- set tearoff [expr {![string compare $tcl_platform(platform) "unix"] \
- || ![string compare [$menu cget -type] "tearoff"]}]
+ set tearoff [expr {[string equal $tcl_platform(platform) "unix"] \
+ || [string equal [$menu cget -type] "tearoff"]}]
if {[string first $w $menu] != 0} {
error "can't post $menu: it isn't a descendant of $w (this is a new requirement in Tk versions 3.0 and later)"
}
@@ -276,7 +276,7 @@ proc tkMbPost {w {x {}} {y {}}} {
update idletasks
if {[catch {
- switch [$w cget -direction] {
+ switch [$w cget -direction] {
above {
set x [winfo rootx $w]
set y [expr {[winfo rooty $w] - [winfo reqheight $menu]}]
@@ -301,7 +301,7 @@ proc tkMbPost {w {x {}} {y {}}} {
}
}
$menu post $x $y
- if {[string compare $entry {}] && [string compare [$menu entrycget $entry -state] "disabled"]} {
+ if {[string compare $entry {}] && [string compare [$menu entrycget $entry -state] "disabled"]} {
$menu activate $entry
tkGenerateMenuSelect $menu
}
@@ -320,14 +320,14 @@ proc tkMbPost {w {x {}} {y {}}} {
}
}
$menu post $x $y
- if {[string compare $entry {}] && [string compare [$menu entrycget $entry -state] "disabled"]} {
+ if {[string compare $entry {}] && [string compare [$menu entrycget $entry -state] "disabled"]} {
$menu activate $entry
tkGenerateMenuSelect $menu
}
}
default {
if {[$w cget -indicatoron]} {
- if {![string compare $y {}]} {
+ if {[string equal $y {}]} {
set x [expr {[winfo rootx $w] + [winfo width $w]/2}]
set y [expr {[winfo rooty $w] + [winfo height $w]/2}]
}
@@ -336,8 +336,8 @@ proc tkMbPost {w {x {}} {y {}}} {
$menu post [winfo rootx $w] [expr {[winfo rooty $w]+[winfo height $w]}]
}
}
- }
- } msg]} {
+ }
+ } msg]} {
# Error posting menu (e.g. bogus -postcommand). Unpost it and
# reflect the error.
@@ -387,17 +387,17 @@ proc tkMenuUnpost menu {
# what was posted.
catch {
- if {[string compare $mb ""]} {
+ if {[string compare $mb ""]} {
set menu [$mb cget -menu]
$menu unpost
set tkPriv(postedMb) {}
$mb configure -cursor $tkPriv(cursor)
$mb configure -relief $tkPriv(relief)
- } elseif {[string compare $tkPriv(popup) ""]} {
+ } elseif {[string compare $tkPriv(popup) ""]} {
$tkPriv(popup) unpost
set tkPriv(popup) {}
- } elseif {[string compare [$menu cget -type] "menubar"]
- && [string compare [$menu cget -type] "tearoff"]} {
+ } elseif {[string compare [$menu cget -type] "menubar"] \
+ && [string compare [$menu cget -type] "tearoff"]} {
# We're in a cascaded sub-menu from a torn-off menu or popup.
# Unpost all the menus up to the toplevel one (but not
# including the top-level torn-off one) and deactivate the
@@ -405,7 +405,7 @@ proc tkMenuUnpost menu {
while 1 {
set parent [winfo parent $menu]
- if {[string compare [winfo class $parent] "Menu"]
+ if {[string compare [winfo class $parent] "Menu"] \
|| ![winfo ismapped $parent]} {
break
}
@@ -413,13 +413,13 @@ proc tkMenuUnpost menu {
$parent postcascade none
tkGenerateMenuSelect $parent
set type [$parent cget -type]
- if {![string compare $type "menubar"] ||
- ![string compare $type "tearoff"]} {
+ if {[string equal $type "menubar"] || \
+ [string equal $type "tearoff"]} {
break
}
set menu $parent
}
- if {[string compare [$menu cget -type] "menubar"]} {
+ if {[string compare [$menu cget -type] "menubar"]} {
$menu unpost
}
}
@@ -428,18 +428,18 @@ proc tkMenuUnpost menu {
if {($tkPriv(tearoff) != 0) || [string compare $tkPriv(menuBar) ""]} {
# Release grab, if any, and restore the previous grab, if there
# was one.
- if {[string compare $menu ""]} {
+ if {[string compare $menu ""]} {
set grab [grab current $menu]
- if {[string compare $grab ""]} {
+ if {[string compare $grab ""]} {
grab release $grab
}
}
tkRestoreOldGrab
- if {[string compare $tkPriv(menuBar) ""]} {
+ if {[string compare $tkPriv(menuBar) ""]} {
$tkPriv(menuBar) configure -cursor $tkPriv(cursor)
set tkPriv(menuBar) {}
}
- if {[string compare $tcl_platform(platform) "unix"]} {
+ if {[string compare $tcl_platform(platform) "unix"]} {
set tkPriv(tearoff) 0
}
}
@@ -459,21 +459,21 @@ proc tkMenuUnpost menu {
proc tkMbMotion {w upDown rootx rooty} {
global tkPriv
- if {![string compare $tkPriv(inMenubutton) $w]} {
+ if {[string equal $tkPriv(inMenubutton) $w]} {
return
}
set new [winfo containing $rootx $rooty]
- if {[string compare $new $tkPriv(inMenubutton)]
- && (![string compare $new ""]
- || ![string compare [winfo toplevel $new] [winfo toplevel $w]])} {
- if {[string compare $tkPriv(inMenubutton) ""]} {
+ if {[string compare $new $tkPriv(inMenubutton)] \
+ && ([string equal $new ""] \
+ || [string equal [winfo toplevel $new] [winfo toplevel $w]])} {
+ if {[string compare $tkPriv(inMenubutton) ""]} {
tkMbLeave $tkPriv(inMenubutton)
}
- if {[string compare $new ""]
- && ![string compare [winfo class $new] "Menubutton"]
- && ([$new cget -indicatoron] == 0)
+ if {[string compare $new ""] \
+ && [string equal [winfo class $new] "Menubutton"] \
+ && ([$new cget -indicatoron] == 0) \
&& ([$w cget -indicatoron] == 0)} {
- if {![string compare $upDown "down"]} {
+ if {[string equal $upDown "down"]} {
tkMbPost $new $rootx $rooty
} else {
tkMbEnter $new
@@ -495,10 +495,11 @@ proc tkMbButtonUp w {
global tcl_platform
set menu [$w cget -menu]
- set tearoff [expr {($tcl_platform(platform) == "unix") \
- || (($menu != {}) && ([$menu cget -type] == "tearoff"))}]
- if {($tearoff != 0) && ($tkPriv(postedMb) == $w)
- && ($tkPriv(inMenubutton) == $w)} {
+ set tearoff [expr {[string equal $tcl_platform(platform) "unix"] || \
+ ([string compare $menu {}] && \
+ [string equal [$menu cget -type] "tearoff"])}]
+ if {($tearoff != 0) && [string equal $tkPriv(postedMb) $w] \
+ && [string equal $tkPriv(inMenubutton) $w]} {
tkMenuFirstEntry [$tkPriv(postedMb) cget -menu]
} else {
tkMenuUnpost {}
@@ -520,10 +521,10 @@ proc tkMbButtonUp w {
proc tkMenuMotion {menu x y state} {
global tkPriv
- if {![string compare $menu $tkPriv(window)]} {
- if {![string compare [$menu cget -type] "menubar"]} {
+ if {[string equal $menu $tkPriv(window)]} {
+ if {[string equal [$menu cget -type] "menubar"]} {
if {[info exists tkPriv(focus)] && \
- [string compare $menu $tkPriv(focus)]} {
+ [string compare $menu $tkPriv(focus)]} {
$menu activate @$x,$y
tkGenerateMenuSelect $menu
}
@@ -563,13 +564,13 @@ proc tkMenuButtonDown menu {
if {[string compare $tkPriv(postedMb) ""]} {
grab -global $tkPriv(postedMb)
} else {
- while {![string compare [$menu cget -type] "normal"]
- && ![string compare [winfo class [winfo parent $menu]] "Menu"]
+ while {[string equal [$menu cget -type] "normal"] \
+ && [string equal [winfo class [winfo parent $menu]] "Menu"] \
&& [winfo ismapped [winfo parent $menu]]} {
set menu [winfo parent $menu]
}
- if {![string compare $tkPriv(menuBar) {}]} {
+ if {[string equal $tkPriv(menuBar) {}]} {
set tkPriv(menuBar) $menu
set tkPriv(cursor) [$menu cget -cursor]
$menu configure -cursor arrow
@@ -580,14 +581,14 @@ proc tkMenuButtonDown menu {
# restore the grab, since the old grab window will not be viewable
# anymore.
- if {[string compare $menu [grab current $menu]]} {
+ if {[string compare $menu [grab current $menu]]} {
tkSaveGrabInfo $menu
}
# Must re-grab even if the grab window hasn't changed, in order
# to release the implicit grab from the button press.
- if {![string compare $tcl_platform(platform) "unix"]} {
+ if {[string equal $tcl_platform(platform) "unix"]} {
grab -global $menu
}
}
@@ -606,11 +607,11 @@ proc tkMenuButtonDown menu {
proc tkMenuLeave {menu rootx rooty state} {
global tkPriv
set tkPriv(window) {}
- if {![string compare [$menu index active] "none"]} {
+ if {[string equal [$menu index active] "none"]} {
return
}
- if {![string compare [$menu type active] "cascade"]
- && ![string compare [winfo containing $rootx $rooty] \
+ if {[string equal [$menu type active] "cascade"]
+ && [string equal [winfo containing $rootx $rooty] \
[$menu entrycget active -menu]]} {
return
}
@@ -631,7 +632,7 @@ proc tkMenuLeave {menu rootx rooty state} {
proc tkMenuInvoke {w buttonRelease} {
global tkPriv
- if {$buttonRelease && ![string compare $tkPriv(window) {}]} {
+ if {$buttonRelease && [string equal $tkPriv(window) {}]} {
# Mouse was pressed over a menu without a menu button, then
# dragged off the menu (possibly with a cascade posted) and
# released. Unpost everything and quit.
@@ -642,14 +643,14 @@ proc tkMenuInvoke {w buttonRelease} {
tkMenuUnpost $w
return
}
- if {![string compare [$w type active] "cascade"]} {
+ if {[string equal [$w type active] "cascade"]} {
$w postcascade active
set menu [$w entrycget active -menu]
tkMenuFirstEntry $menu
- } elseif {![string compare [$w type active] "tearoff"]} {
+ } elseif {[string equal [$w type active] "tearoff"]} {
tkMenuUnpost $w
tkTearOffMenu $w
- } elseif {![string compare [$w cget -type] "menubar"]} {
+ } elseif {[string equal [$w cget -type] "menubar"]} {
$w postcascade none
$w activate none
event generate $w <<MenuSelect>>
@@ -672,7 +673,7 @@ proc tkMenuEscape menu {
set parent [winfo parent $menu]
if {[string compare [winfo class $parent] "Menu"]} {
tkMenuUnpost $menu
- } elseif {![string compare [$parent cget -type] "menubar"]} {
+ } elseif {[string equal [$parent cget -type] "menubar"]} {
tkMenuUnpost $menu
tkRestoreOldGrab
} else {
@@ -684,7 +685,7 @@ proc tkMenuEscape menu {
# differently depending on whether the menu is a menu bar or not.
proc tkMenuUpArrow {menu} {
- if {![string compare [$menu cget -type] "menubar"]} {
+ if {[string equal [$menu cget -type] "menubar"]} {
tkMenuNextMenu $menu left
} else {
tkMenuNextEntry $menu -1
@@ -692,7 +693,7 @@ proc tkMenuUpArrow {menu} {
}
proc tkMenuDownArrow {menu} {
- if {![string compare [$menu cget -type] "menubar"]} {
+ if {[string equal [$menu cget -type] "menubar"]} {
tkMenuNextMenu $menu right
} else {
tkMenuNextEntry $menu 1
@@ -700,7 +701,7 @@ proc tkMenuDownArrow {menu} {
}
proc tkMenuLeftArrow {menu} {
- if {![string compare [$menu cget -type] "menubar"]} {
+ if {[string equal [$menu cget -type] "menubar"]} {
tkMenuNextEntry $menu -1
} else {
tkMenuNextMenu $menu left
@@ -708,7 +709,7 @@ proc tkMenuLeftArrow {menu} {
}
proc tkMenuRightArrow {menu} {
- if {![string compare [$menu cget -type] "menubar"]} {
+ if {[string equal [$menu cget -type] "menubar"]} {
tkMenuNextEntry $menu 1
} else {
tkMenuNextMenu $menu right
@@ -730,22 +731,22 @@ proc tkMenuNextMenu {menu direction} {
# First handle traversals into and out of cascaded menus.
- if {![string compare $direction "right"]} {
+ if {[string equal $direction "right"]} {
set count 1
set parent [winfo parent $menu]
set class [winfo class $parent]
- if {![string compare [$menu type active] "cascade"]} {
+ if {[string equal [$menu type active] "cascade"]} {
$menu postcascade active
set m2 [$menu entrycget active -menu]
- if {[string compare $m2 ""]} {
+ if {[string compare $m2 ""]} {
tkMenuFirstEntry $m2
}
return
} else {
set parent [winfo parent $menu]
- while {[string compare $parent "."]} {
- if {![string compare [winfo class $parent] "Menu"]
- && ![string compare [$parent cget -type] "menubar"]} {
+ while {[string compare $parent "."]} {
+ if {[string equal [winfo class $parent] "Menu"] \
+ && [string equal [$parent cget -type] "menubar"]} {
tk_menuSetFocus $parent
tkMenuNextEntry $parent 1
return
@@ -756,8 +757,8 @@ proc tkMenuNextMenu {menu direction} {
} else {
set count -1
set m2 [winfo parent $menu]
- if {![string compare [winfo class $m2] "Menu"]} {
- if {[string compare [$m2 cget -type] "menubar"]} {
+ if {[string equal [winfo class $m2] "Menu"]} {
+ if {[string compare [$m2 cget -type] "menubar"]} {
$menu activate none
tkGenerateMenuSelect $menu
tk_menuSetFocus $m2
@@ -776,8 +777,8 @@ proc tkMenuNextMenu {menu direction} {
# or previous menubutton, if that makes sense.
set m2 [winfo parent $menu]
- if {![string compare [winfo class $m2] "Menu"]} {
- if {![string compare [$m2 cget -type] "menubar"]} {
+ if {[string equal [winfo class $m2] "Menu"]} {
+ if {[string equal [$m2 cget -type] "menubar"]} {
tk_menuSetFocus $m2
tkMenuNextEntry $m2 -1
return
@@ -785,7 +786,7 @@ proc tkMenuNextMenu {menu direction} {
}
set w $tkPriv(postedMb)
- if {![string compare $w ""]} {
+ if {[string equal $w ""]} {
return
}
set buttons [winfo children [winfo parent $w]]
@@ -799,13 +800,13 @@ proc tkMenuNextMenu {menu direction} {
incr i -$length
}
set mb [lindex $buttons $i]
- if {![string compare [winfo class $mb] "Menubutton"]
- && [string compare [$mb cget -state] "disabled"]
- && [string compare [$mb cget -menu] ""]
- && [string compare [[$mb cget -menu] index last] "none"]} {
+ if {[string equal [winfo class $mb] "Menubutton"] \
+ && [string compare [$mb cget -state] "disabled"] \
+ && [string compare [$mb cget -menu] ""] \
+ && [string compare [[$mb cget -menu] index last] "none"]} {
break
}
- if {![string compare $mb $w]} {
+ if {[string equal $mb $w]} {
return
}
incr i $count
@@ -826,13 +827,13 @@ proc tkMenuNextMenu {menu direction} {
proc tkMenuNextEntry {menu count} {
global tkPriv
- if {![string compare [$menu index last] "none"]} {
+ if {[string equal [$menu index last] "none"]} {
return
}
set length [expr {[$menu index last]+1}]
set quitAfter $length
set active [$menu index active]
- if {![string compare $active "none"]} {
+ if {[string equal $active "none"]} {
set i 0
} else {
set i [expr {$active + $count}]
@@ -851,7 +852,7 @@ proc tkMenuNextEntry {menu count} {
incr i -$length
}
if {[catch {$menu entrycget $i -state} state] == 0} {
- if {$state != "disabled"} {
+ if {[string compare $state "disabled"]} {
break
}
}
@@ -863,9 +864,12 @@ proc tkMenuNextEntry {menu count} {
}
$menu activate $i
tkGenerateMenuSelect $menu
- if {![string compare [$menu type $i] "cascade"]} {
+ if {[string equal [$menu type $i] "cascade"]} {
set cascade [$menu entrycget $i -menu]
- if {[string compare $cascade ""]} {
+ if {[string compare $cascade ""]} {
+ # Here we auto-post a cascade. This is necessary when
+ # we traverse left/right in the menubar, but undesirable when
+ # we traverse up/down in a menu.
$menu postcascade $i
tkMenuFirstEntry $cascade
}
@@ -895,29 +899,27 @@ proc tkMenuFind {w char} {
foreach child $windowlist {
# Don't descend into other toplevels.
- if {[winfo toplevel [focus]] != [winfo toplevel $child] } {
+ if {[string compare [winfo toplevel [focus]] \
+ [winfo toplevel $child]]} {
continue
}
- switch [winfo class $child] {
- Menu {
- if {![string compare [$child cget -type] "menubar"]} {
- if {![string compare $char ""]} {
+ if {[string equal [winfo class $child] "Menu"] && \
+ [string equal [$child cget -type] "menubar"]} {
+ if {[string equal $char ""]} {
+ return $child
+ }
+ set last [$child index last]
+ for {set i [$child cget -tearoff]} {$i <= $last} {incr i} {
+ if {[string equal [$child type $i] "separator"]} {
+ continue
+ }
+ set char2 [string index [$child entrycget $i -label] \
+ [$child entrycget $i -underline]]
+ if {[string equal $char [string tolower $char2]] \
+ || [string equal $char ""]} {
+ if {[string compare [$child entrycget $i -state] "disabled"]} {
return $child
}
- set last [$child index last]
- for {set i [$child cget -tearoff]} {$i <= $last} {incr i} {
- if {![string compare [$child type $i] "separator"]} {
- continue
- }
- set char2 [string index [$child entrycget $i -label] \
- [$child entrycget $i -underline]]
- if {![string compare $char [string tolower $char2]] \
- || ![string compare $char ""]} {
- if {[string compare [$child entrycget $i -state] "disabled"]} {
- return $child
- }
- }
- }
}
}
}
@@ -925,16 +927,17 @@ proc tkMenuFind {w char} {
foreach child $windowlist {
# Don't descend into other toplevels.
- if {[winfo toplevel [focus]] != [winfo toplevel $child] } {
+ if {[string compare [winfo toplevel [focus]] \
+ [winfo toplevel $child]]} {
continue
}
switch [winfo class $child] {
Menubutton {
set char2 [string index [$child cget -text] \
[$child cget -underline]]
- if {![string compare $char [string tolower $char2]]
- || ![string compare $char ""]} {
- if {[string compare [$child cget -state] "disabled"]} {
+ if {[string equal $char [string tolower $char2]] \
+ || [string equal $char ""]} {
+ if {[string compare [$child cget -state] "disabled"]} {
return $child
}
}
@@ -942,7 +945,7 @@ proc tkMenuFind {w char} {
default {
set match [tkMenuFind $child $char]
- if {[string compare $match ""]} {
+ if {[string compare $match ""]} {
return $match
}
}
@@ -965,22 +968,22 @@ proc tkMenuFind {w char} {
proc tkTraverseToMenu {w char} {
global tkPriv
- if {![string compare $char ""]} {
+ if {[string equal $char ""]} {
return
}
- while {![string compare [winfo class $w] "Menu"]} {
- if {[string compare [$w cget -type] "menubar"]
- && ![string compare $tkPriv(postedMb) ""]} {
+ while {[string equal [winfo class $w] "Menu"]} {
+ if {[string compare [$w cget -type] "menubar"] \
+ && [string equal $tkPriv(postedMb) ""]} {
return
}
- if {![string compare [$w cget -type] "menubar"]} {
+ if {[string equal [$w cget -type] "menubar"]} {
break
}
set w [winfo parent $w]
}
set w [tkMenuFind [winfo toplevel $w] $char]
if {[string compare $w ""]} {
- if {![string compare [winfo class $w] "Menu"]} {
+ if {[string equal [winfo class $w] "Menu"]} {
tk_menuSetFocus $w
set tkPriv(window) $w
tkSaveGrabInfo $w
@@ -1004,7 +1007,7 @@ proc tkTraverseToMenu {w char} {
proc tkFirstMenu w {
set w [tkMenuFind [winfo toplevel $w] ""]
if {[string compare $w ""]} {
- if {![string compare [winfo class $w] "Menu"]} {
+ if {[string equal [winfo class $w] "Menu"]} {
tk_menuSetFocus $w
set tkPriv(window) $w
tkSaveGrabInfo $w
@@ -1029,27 +1032,26 @@ proc tkFirstMenu w {
# nothing happens.
proc tkTraverseWithinMenu {w char} {
- if {![string compare $char ""]} {
+ if {[string equal $char ""]} {
return
}
set char [string tolower $char]
set last [$w index last]
- if {![string compare $last "none"]} {
+ if {[string equal $last "none"]} {
return
}
for {set i 0} {$i <= $last} {incr i} {
if {[catch {set char2 [string index \
- [$w entrycget $i -label] \
- [$w entrycget $i -underline]]}]} {
+ [$w entrycget $i -label] [$w entrycget $i -underline]]}]} {
continue
}
- if {![string compare $char [string tolower $char2]]} {
- if {![string compare [$w type $i] "cascade"]} {
+ if {[string equal $char [string tolower $char2]]} {
+ if {[string equal [$w type $i] "cascade"]} {
$w activate $i
$w postcascade active
event generate $w <<MenuSelect>>
set m2 [$w entrycget $i -menu]
- if {[string compare $m2 ""]} {
+ if {[string compare $m2 ""]} {
tkMenuFirstEntry $m2
}
} else {
@@ -1073,7 +1075,7 @@ proc tkTraverseWithinMenu {w char} {
# menu - Name of the menu window (possibly empty).
proc tkMenuFirstEntry menu {
- if {![string compare $menu ""]} {
+ if {[string equal $menu ""]} {
return
}
tk_menuSetFocus $menu
@@ -1081,18 +1083,18 @@ proc tkMenuFirstEntry menu {
return
}
set last [$menu index last]
- if {![string compare $last "none"]} {
+ if {[string equal $last "none"]} {
return
}
for {set i 0} {$i <= $last} {incr i} {
- if {([catch {set state [$menu entrycget $i -state]}] == 0)
- && [string compare $state "disabled"]
- && [string compare [$menu type $i] "tearoff"]} {
+ if {([catch {set state [$menu entrycget $i -state]}] == 0) \
+ && [string compare $state "disabled"] \
+ && [string compare [$menu type $i] "tearoff"]} {
$menu activate $i
tkGenerateMenuSelect $menu
- if {![string compare [$menu type $i] "cascade"]} {
+ if {[string equal [$menu type $i] "cascade"]} {
set cascade [$menu entrycget $i -menu]
- if {[string compare $cascade ""]} {
+ if {[string compare $cascade ""]} {
$menu postcascade $i
tkMenuFirstEntry $cascade
}
@@ -1120,12 +1122,12 @@ proc tkMenuFindName {menu s} {
return $i
}
set last [$menu index last]
- if {![string compare $last "none"]} {
+ if {[string equal $last "none"]} {
return
}
for {set i 0} {$i <= $last} {incr i} {
if {![catch {$menu entrycget $i -label} label]} {
- if {![string compare $label $s]} {
+ if {[string equal $label $s]} {
return $i
}
}
@@ -1159,8 +1161,8 @@ proc tkPostOverPoint {menu x y {entry {}}} {
incr x [expr {-[winfo reqwidth $menu]/2}]
}
$menu post $x $y
- if {[string compare $entry {}]
- && [string compare [$menu entrycget $entry -state] "disabled"]} {
+ if {[string compare $entry {}] \
+ && [string compare [$menu entrycget $entry -state] "disabled"]} {
$menu activate $entry
tkGenerateMenuSelect $menu
}
@@ -1195,7 +1197,7 @@ proc tkRestoreOldGrab {} {
# be visible anymore.
catch {
- if {![string compare $tkPriv(grabStatus) "global"]} {
+ if {[string equal $tkPriv(grabStatus) "global"]} {
grab set -global $tkPriv(oldGrab)
} else {
grab set $tkPriv(oldGrab)
@@ -1207,7 +1209,7 @@ proc tkRestoreOldGrab {} {
proc tk_menuSetFocus {menu} {
global tkPriv
- if {![info exists tkPriv(focus)] || ![string compare $tkPriv(focus) {}]} {
+ if {![info exists tkPriv(focus)] || [string equal $tkPriv(focus) {}]} {
set tkPriv(focus) [focus]
}
focus $menu
@@ -1216,8 +1218,8 @@ proc tk_menuSetFocus {menu} {
proc tkGenerateMenuSelect {menu} {
global tkPriv
- if {![string compare $tkPriv(activeMenu) $menu] \
- && ![string compare $tkPriv(activeItem) [$menu index active]]} {
+ if {[string equal $tkPriv(activeMenu) $menu] \
+ && [string equal $tkPriv(activeItem) [$menu index active]]} {
return
}
@@ -1241,12 +1243,12 @@ proc tkGenerateMenuSelect {menu} {
proc tk_popup {menu x y {entry {}}} {
global tkPriv
global tcl_platform
- if {[string compare $tkPriv(popup) ""]
- || [string compare $tkPriv(postedMb) ""]} {
+ if {[string compare $tkPriv(popup) ""] \
+ || [string compare $tkPriv(postedMb) ""]} {
tkMenuUnpost {}
}
tkPostOverPoint $menu $x $y $entry
- if {![string compare $tcl_platform(platform) "unix"] \
+ if {[string equal $tcl_platform(platform) "unix"] \
&& [winfo viewable $menu]} {
tkSaveGrabInfo $menu
grab -global $menu