summaryrefslogtreecommitdiffstats
path: root/library/menu.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'library/menu.tcl')
-rw-r--r--library/menu.tcl82
1 files changed, 40 insertions, 42 deletions
diff --git a/library/menu.tcl b/library/menu.tcl
index c4991f8..823fd69 100644
--- a/library/menu.tcl
+++ b/library/menu.tcl
@@ -6,7 +6,7 @@
#
# Copyright (c) 1992-1994 The Regents of the University of California.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
-# Copyright (c) 1998-1999 by Scriptics Corporation.
+# Copyright (c) 1998-1999 Scriptics Corporation.
# Copyright (c) 2007 Daniel A. Steffen <das@users.sourceforge.net>
#
# See the file "license.terms" for information on usage and redistribution
@@ -269,8 +269,8 @@ proc ::tk::MbPost {w {x {}} {y {}}} {
MenuUnpost {}
}
if {$::tk_strictMotif} {
- set Priv(cursor) [$w cget -cursor]
- $w configure -cursor arrow
+ set Priv(cursor) [$w cget -cursor]
+ $w configure -cursor arrow
}
if {[tk windowingsystem] ne "aqua"} {
set Priv(relief) [$w cget -relief]
@@ -343,7 +343,7 @@ proc ::tk::MenuUnpost menu {
$menu unpost
set Priv(postedMb) {}
if {$::tk_strictMotif} {
- $mb configure -cursor $Priv(cursor)
+ $mb configure -cursor $Priv(cursor)
}
if {[tk windowingsystem] ne "aqua"} {
$mb configure -relief $Priv(relief)
@@ -475,7 +475,7 @@ proc ::tk::MbButtonUp w {
proc ::tk::MenuMotion {menu x y state} {
variable ::tk::Priv
if {$menu eq $Priv(window)} {
- set activeindex [$menu index active]
+ set active [$menu index active]
if {[$menu cget -type] eq "menubar"} {
if {[info exists Priv(focus)] && $menu ne $Priv(focus)} {
$menu activate @$x,$y
@@ -485,24 +485,24 @@ proc ::tk::MenuMotion {menu x y state} {
$menu activate @$x,$y
GenerateMenuSelect $menu
}
- set index [$menu index @$x,$y]
- if {[info exists Priv(menuActivated)] \
- && $index ne "none" \
- && $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}]
- if {[$menu type $index] eq "cascade"} {
- # Catch these postcascade commands since the menu could be
- # destroyed before they run.
- set Priv(menuActivatedTimer) \
- [after $delay "catch {$menu postcascade active}"]
- } else {
- set Priv(menuDeactivatedTimer) \
- [after $delay "catch {$menu postcascade none}"]
- }
- }
- }
+ set index [$menu index @$x,$y]
+ if {[info exists Priv(menuActivated)] \
+ && $index ne "none" \
+ && $index ne $active} {
+ set mode [option get $menu clickToFocus ClickToFocus]
+ if {[string is false $mode]} {
+ set delay [expr {[$menu cget -type] eq "menubar" ? 0 : 50}]
+ if {[$menu type $index] eq "cascade"} {
+ # Catch these postcascade commands since the menu could be
+ # destroyed before they run.
+ set Priv(menuActivatedTimer) \
+ [after $delay "catch {$menu postcascade active}"]
+ } else {
+ set Priv(menuDeactivatedTimer) \
+ [after $delay "catch {$menu postcascade none}"]
+ }
+ }
+ }
}
}
@@ -525,13 +525,13 @@ proc ::tk::MenuButtonDown menu {
variable ::tk::Priv
if {![winfo viewable $menu]} {
- return
+ return
}
if {[$menu index active] eq "none"} {
- if {[$menu cget -type] ne "menubar" } {
- set Priv(window) {}
- }
- return
+ if {[$menu cget -type] ne "menubar" } {
+ set Priv(window) {}
+ }
+ return
}
$menu postcascade active
if {$Priv(postedMb) ne "" && [winfo viewable $Priv(postedMb)]} {
@@ -552,7 +552,7 @@ proc ::tk::MenuButtonDown menu {
if {[$menu type active] eq "cascade"} {
set Priv(menuActivated) 1
}
- }
+ }
# Don't update grab information if the grab window isn't changing.
# Otherwise, we'll get an error when we unpost the menus and
@@ -893,7 +893,7 @@ proc ::tk::MenuFind {w char} {
foreach child $windowlist {
# Don't descend into other toplevels.
- if {[winfo toplevel $w] ne [winfo toplevel $child]} {
+ if {[winfo toplevel $w] ne [winfo toplevel $child]} {
continue
}
if {[winfo class $child] eq "Menu" && \
@@ -919,7 +919,7 @@ proc ::tk::MenuFind {w char} {
foreach child $windowlist {
# Don't descend into other toplevels.
- if {[winfo toplevel $w] ne [winfo toplevel $child]} {
+ if {[winfo toplevel $w] ne [winfo toplevel $child]} {
continue
}
switch -- [winfo class $child] {
@@ -941,7 +941,7 @@ proc ::tk::MenuFind {w char} {
}
}
}
- return {}
+ return ""
}
# ::tk::TraverseToMenu --
@@ -1115,7 +1115,7 @@ proc ::tk::MenuFindName {menu s} {
}
set last [$menu index last]
if {$last eq "none"} {
- return
+ return ""
}
for {set i 0} {$i <= $last} {incr i} {
if {![catch {$menu entrycget $i -label} label]} {
@@ -1186,7 +1186,7 @@ if {[tk windowingsystem] eq "aqua"} {
# if we go offscreen to the top, show as 'below'
if {$y < [winfo vrooty $button]} {
set y [expr {[winfo vrooty $button] + [winfo rooty $button]\
- + [winfo reqheight $button]}]
+ + [winfo reqheight $button]}]
}
set entry {}
}
@@ -1340,14 +1340,12 @@ proc ::tk_menuSetFocus {menu} {
proc ::tk::GenerateMenuSelect {menu} {
variable ::tk::Priv
- if {$Priv(activeMenu) eq $menu \
- && $Priv(activeItem) eq [$menu index active]} {
- return
+ if {$Priv(activeMenu) ne $menu \
+ || $Priv(activeItem) ne [$menu index active]} {
+ set Priv(activeMenu) $menu
+ set Priv(activeItem) [$menu index active]
+ event generate $menu <<MenuSelect>>
}
-
- set Priv(activeMenu) $menu
- set Priv(activeItem) [$menu index active]
- event generate $menu <<MenuSelect>>
}
# ::tk_popup --
@@ -1369,7 +1367,7 @@ proc ::tk_popup {menu x y {entry {}}} {
}
tk::PostOverPoint $menu $x $y $entry
if {[tk windowingsystem] eq "x11" && [winfo viewable $menu]} {
- tk::SaveGrabInfo $menu
+ tk::SaveGrabInfo $menu
grab -global $menu
set Priv(popup) $menu
set Priv(window) $menu