Tk Source Code

Artifact [a14aa80f]
Login

Artifact a14aa80f83aaa9de07b7c2d7d1f3277cd03a65f5:

Attachment "menuButtonTest.tcl" to ticket [680884ff] added by vincentdarley 2003-02-05 21:37:22.
catch {console show}

menubutton .one -text "one" -menu .one.m
menubutton .two -text "two" -menu .two.m
pack .one
pack .two

bind .one <Button-1> [list makeMenu .one]
bind .two <Button-1> [list makeMenu .two]

proc makeMenu {w} {
    set m $w.m
    catch {destroy $w.m}
    menu $w.m
    # In my app, the menu is built by communicating 
    # with a remote cvs server.
    $w.m add command -label "a"
    $w.m add command -label "b"
    # Now need a time-consuming calculation
    after 2000 [list set ::foo 1]
    vwait ::foo
}

raise .

# Now click on menu 'one', but while you 
# are waiting for it to popup, move the 
# mouse over menu 'two'.  
# 
# You will get the following bgerror:
# 
# invalid command name ".two.m"
#     while executing
# "$menu cget -type"
#     (procedure "MbPost" line 13)
#     invoked from within
# "MbPost $new $rootx $rooty"
#     (procedure "tk::MbMotion" line 14)
#     invoked from within
# "tk::MbMotion .one down 95 93
# "
#     (command bound to event)