In lib/ttk/button.tcl, there are two bindings (which are later copied to TRadiobutton and TCheckbutton as well):
bind TButton <Key-space> { ttk::button::activate %W }
bind TButton <<Invoke>> { ttk::button::activate %W }
<<Invoke>> is undocumented (it's not on the [event] manpage's list of Pre-Defined Events, or mentioned on the [ttk::button] manpage) - I'm not sure if this is an oversight, or if the binding is only there for backwards compatability or something. But it looks like it should probably either be removed, or should be documented (and the <Key-space> binding changed to [event add <<Invoke>> <Key-space>] so it's used).
<<Invoke>> cannot be added to the virtual events, at least not until Tk 8.7.
I see no added value in defining a virtual event which is equivalent
to <Key-space>, so I would suggest removing it.
Joe?
<<Invoke>> event bindings are used for mnemonic activation and for accelerators, for exaqmple:
bind $dlg <KeyPress-Escape> [list event generate $dlg.cancel <<Invoke>>]
See also the keynav package (which was a part of Tile that Jeff left behind when executing TIP#248),
https://github.com/jenglish/tile-extras/blob/master/keynav.tcl
Please do not remove the <<Invoke>> binding from library/ttk/*.tcl, that will break user code that relies on it.
Do not add <Key-space> as a synonym for <<Invoke>>, that would be incorrect.
OK, so we should document it. That's fine. We could also add it to the bindings put on ordinary *buttons, etc. as it isn't mapped to a key sequence.
The docs really are just a “these are the virtual events used in Tk”, and could probably do with some updating anyway. I suggest something like this shell magic to find things worthy of mentioning (and where to look for the uses of the events):
grep '<<[a-zA-Z0-9]*>>' $(find tk/library -name '*.tcl') | sed 's/\([^:]*\):.*\(<<.*>>\).*/\2: \1/' | sort -u
Don't know if I'll get to doing such an audit in the near future. :-(
>OK, so we should document it
Agreed. <<Invoke>> should be documented as an event which is not
defined by Tk, only used. And - indeed - for consistancy, I would
add <<Invoke>> bindings to other relevant widgets as well
(button, listbox and menu)
> Do not add <Key-space> as a synonym for <<Invoke>>, that
> would be incorrect.
Such addition would mean that the default binding for
<Key-space> changes, a potentional incompatible change
which therefore cannot be done in Tk 8.6.
How about ?:
<http://core.tcl.tk/tk/info/bb6cac1113>
Could this do any harm?
Use of virtual events in the tk script library:
<<AltUnderlined>>: clrpick.tcl, fontchooser.tcl, tk.tcl, tkfbox.tcl, xmfbox.tcl
<<Clear>>: console.tcl, entry.tcl, spinbox.tcl, text.tcl, tk.tcl, ttk/entry.tcl
<<ComboboxSelected>>: demos/toolbar.tcl, ttk/combobox.tcl
<<ContextMenu>>: tk.tcl
<<Copy>>: console.tcl, entry.tcl, listbox.tcl, spinbox.tcl, text.tcl, tk.tcl, ttk/entry.tcl
<<Cut>>: console.tcl, entry.tcl, spinbox.tcl, text.tcl, tk.tcl, ttk/entry.tcl
<<Decrement>>: ttk/spinbox.tcl
<<EnteredChild>>: ttk/panedwindow.tcl
<<Increment>>: ttk/spinbox.tcl
<<Invoke>>: ttk/button.tcl, ttk/menubutton.tcl, ttk/ttk.tcl
<<LineEnd>>: console.tcl, entry.tcl, listbox.tcl, scale.tcl, scrlbar.tcl, spinbox.tcl, text.tcl, tk.tcl, ttk/entry.tcl, ttk/scale.tcl
<<LineStart>>: console.tcl, entry.tcl, listbox.tcl, scale.tcl, scrlbar.tcl, spinbox.tcl, text.tcl, tk.tcl, ttk/entry.tcl, ttk/scale.tcl
<<ListboxSelect>>: fontchooser.tcl, iconlist.tcl, listbox.tcl, tkfbox.tcl, xmfbox.tcl
<<MenuSelect>>: demos/menu.tcl, menu.tcl
<<NextChar>>: demos/entry3.tcl, demos/items.tcl, entry.tcl, iconlist.tcl, listbox.tcl, menu.tcl, scale.tcl, scrlbar.tcl, spinbox.tcl, text.tcl, tk.tcl, ttk/entry.tcl, ttk/scale.tcl
<<NextLine>>: console.tcl, entry.tcl, iconlist.tcl, listbox.tcl, menu.tcl, scale.tcl, scrlbar.tcl, spinbox.tcl, text.tcl, tk.tcl, ttk/entry.tcl, ttk/scale.tcl
<<NextPara>>: scale.tcl, scrlbar.tcl, text.tcl, tk.tcl, ttk/scale.tcl
<<NextWindow>>: dialog.tcl, tk.tcl
<<NextWord>>: entry.tcl, listbox.tcl, scale.tcl, scrlbar.tcl, spinbox.tcl, text.tcl, tk.tcl, ttk/entry.tcl, ttk/scale.tcl
<<Paste>>: console.tcl, entry.tcl, spinbox.tcl, text.tcl, tk.tcl, ttk/entry.tcl
<<PasteSelection>>: entry.tcl, spinbox.tcl, text.tcl, tk.tcl, ttk/entry.tcl
<<PrevChar>>: demos/entry3.tcl, entry.tcl, iconlist.tcl, listbox.tcl, menu.tcl, scale.tcl, scrlbar.tcl, spinbox.tcl, text.tcl, tk.tcl, ttk/entry.tcl, ttk/scale.tcl
<<PrevLine>>: console.tcl, entry.tcl, iconlist.tcl, listbox.tcl, menu.tcl, scale.tcl, scrlbar.tcl, spinbox.tcl, text.tcl, tk.tcl, ttk/entry.tcl, ttk/scale.tcl
<<PrevPara>>: scale.tcl, scrlbar.tcl, text.tcl, tk.tcl, ttk/scale.tcl
<<PrevWindow>>: dialog.tcl, tk.tcl, ttk/combobox.tcl
<<PrevWord>>: entry.tcl, listbox.tcl, scale.tcl, scrlbar.tcl, spinbox.tcl, text.tcl, tk.tcl, ttk/entry.tcl, ttk/scale.tcl
<<Redo>>: text.tcl, tk.tcl
<<SelectAll>>: entry.tcl, listbox.tcl, spinbox.tcl, text.tcl, tk.tcl, ttk/entry.tcl
<<SelectLineEnd>>: entry.tcl, spinbox.tcl, text.tcl, tk.tcl, ttk/entry.tcl
<<SelectLineStart>>: entry.tcl, spinbox.tcl, text.tcl, tk.tcl, ttk/entry.tcl
<<SelectNextChar>>: entry.tcl, spinbox.tcl, text.tcl, tk.tcl, ttk/entry.tcl
<<SelectNextLine>>: listbox.tcl, text.tcl, tk.tcl
<<SelectNextPara>>: text.tcl, tk.tcl
<<SelectNextWord>>: entry.tcl, spinbox.tcl, text.tcl, tk.tcl, ttk/entry.tcl
<<SelectNone>>: entry.tcl, listbox.tcl, spinbox.tcl, text.tcl, tk.tcl, ttk/entry.tcl
<<SelectPrevChar>>: entry.tcl, spinbox.tcl, text.tcl, tk.tcl, ttk/entry.tcl
<<SelectPrevLine>>: listbox.tcl, text.tcl, tk.tcl
<<SelectPrevPara>>: text.tcl, tk.tcl
<<SelectPrevWord>>: entry.tcl, spinbox.tcl, text.tcl, tk.tcl, ttk/entry.tcl
<<ThemeChanged>>: fontchooser.tcl, ttk/ttk.tcl
<<TkFontchooserFontChanged>>: fontchooser.tcl
<<TkFontchooserVisibility>>: console.tcl, demos/fontchoose.tcl, demos/text.tcl, fontchooser.tcl
<<ToggleSelection>>: tk.tcl, ttk/entry.tcl, ttk/treeview.tcl
<<TraverseIn>>: entry.tcl, spinbox.tcl, tk.tcl, ttk/combobox.tcl, ttk/entry.tcl, ttk/utils.tcl
<<TraverseOut>>: tk.tcl, ttk/utils.tcl
<<TreeviewClose>>: ttk/treeview.tcl
<<TreeviewOpen>>: demos/tree.tcl, ttk/treeview.tcl
<<Undo>>: text.tcl, tk.tcl
<http://core.tcl.tk/tk/info/bb6cac1113> is probably OK. Documentation is more important.
Re-opening, as this is in fact mainly a documentation 'bug', not 'invalid'.
Added documentation for <<EnteredChild>>, <<Invoke>>, <<Increment>> and <<Decrement>>.
Please evaluate. <http://core.tcl.tk/tk/ci/1249c24fef?sbs=1>
For <<ThemeChanged>> I'm not sure where to put it: In Tk 8.5 it is not used anywhere
in Tk, so I would expect it to be documented somewhere in ttk. However, in Tk 8.6 it is
used by the fontchooser widget, so I would expect it in event.n.
Looks good, except that event.n should list all virtual events in use so that there is one place that people can go to look for potential clashes when they define their own events.
>Looks good, except that event.n should list all virtual events in use so
>that there is one place that people can go to look for potential clashes
>when they define their own events.
For <<Invoke>> and <<ThemeChanged>>, I agree. But for <<Increment>>/
<<Decrement>> (for spinbox only), <<EnteredChild>> (for panedwindow only),
which are used in a single widget and not "event add"ed, there is
no possible conflict: Even if people would use <<Increment>> in their
own widgets, that still doesn't cause any problem for the spinbox/panedwindow.
This makes me wonder why <<Selection>>,
<<MenuSelect>>, <<ListboxSelect>>, <<ComboboxSelected>>,
<<TreeviewSelect>> all have a different
name. It wouldn't cause a conflict if they were all
named <<Selection>>, do they? But that's possibly
for Tk 9.0, not for Tk 8.6. Therefore, I would prefer not
to document <<ComboboxSelected>> and
<<TreeviewSelect>> in event.n now, just leave it
in ttk_combobox.n/ttk_treeview.n. Please correct me
if I'm wrong.
Committed now to core-8-5-branch and trunk