Posted to tcl by jenglish at Tue Jul 11 01:22:24 GMT 2006view pretty
package require Tk option add *tearOff false variable mute 0 proc muteChanged {} { global mute puts "mute=$mute" } . configure -menu [menu .menu] .menu add cascade -label "Test" -menu [menu .menu.test] -underline 0 .menu.test add checkbutton \ -label "Mute" -variable mute -command muteChanged \ -underline 0 -accelerator Ctrl-M \ ; # The <Alt-KeyPress-t> accelerator automatically pops down the "Test" menu, # and the "m" mnemonic will automatically toggle the "Mute" entry. # However, you need to add the Ctrl-M accelerator by hand: # bind . <Control-KeyPress-m> { toggleMute } proc toggleMute {} { global mute; set mute [expr {!$mute}] muteChanged } pack [entry .e] -expand false -fill x ; focus .e
Comments
Posted by tom at Tue Jul 11 01:32:30 GMT 2006 [text] [code]
This code by jenglish solves the problem of updating the check-mark of the menu-entry when using accelerator key. So the status is shown always correctly. Great code. Thx a lot jenglish.