event add <<virtual>> sequence ?sequence ...?
event delete <<virtual>> ?sequence sequence ...?
event generate window event ?option value option value ...?
event info ?<<virtual>>?
http://purl.org/tcl/home/man/tcl8.4/TkCmd/event.htm
Tested to work on Windows:
event generate . <Alt-F4> ;# sudden death, somehow like [exit]
However, other Alt-(initial) events don't work when called from event, only from the keyboard.
A small proc I wrote for something. It takes two argument, a window and a keysym (http://www.purl.org/tcl/home/man/tcl8.4/TkCmd/keysyms.htm ), and returns a two-element list. Assuming that some action is defined for the window, the first element is /what/ the binding is to, and the second is the command actually run. If someone wants to clean my explaination up a little after looking at the proc, please go ahead, it's not particularly coherent :) -- MG
(%1) proc eventchk {w s} { set ret [list "" ""] ; set list [list "" ""] set tags [bindtags $w] while { $ret == $list && $tags != "" } { if { [bind [lindex $tags 0] $s] != "" } { set ret [list [lindex $tags 0] [bind [lindex $tags 0] $s]] } else { set tags [lrange $tags 1 end] } } return $ret; } (%2) text .t (%3) eventchk .t <Return> Text { tk::TextInsert %W \n if {[%W cget -autoseparators]} {%W edit separator} } (%4) bind .t <Return> {puts "You pressed return" ; break} (%5) eventchk .t <Return> .t {puts "You pressed return" ; break"}
See also:
Tk syntax help - Arts and Crafts of Tcl-Tk Programming - Category Command