Posted to tcl by patthoyts at Wed Dec 23 01:06:27 GMT 2009view pretty

diff --git a/library/menu.tcl b/library/menu.tcl
index a2d9109..2664d96 100644
--- a/library/menu.tcl
+++ b/library/menu.tcl
@@ -406,6 +406,8 @@ proc ::tk::MenuUnpost menu {
     # Unpost menu(s) and restore some stuff that's dependent on
     # what was posted.
 
+    unset -nocomplain Priv(menuActivated)
+
     catch {
        if {$mb ne ""} {
            set menu [$mb cget -menu]
@@ -557,7 +559,7 @@ proc ::tk::MenuMotion {menu x y state} {
            GenerateMenuSelect $menu
        }
     }
-    if {($state & 0x1f00) != 0} {
+    if {[info exists Priv(menuActivated)]} {
        $menu postcascade active
     }
 }
@@ -600,6 +602,9 @@ proc ::tk::MenuButtonDown menu {
                set Priv(cursor) [$menu cget -cursor]
                $menu configure -cursor arrow
            }
+           if {[$menu type active] eq "cascade"} {
+               set Priv(menuActivated) 1
+           }
         }
 
        # Don't update grab information if the grab window isn't changing.