Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Documentation on "bind" would need to be updated

86 views
Skip to first unread message

Robert Csok

unread,
Jan 27, 2020, 8:56:49 AM1/27/20
to
Hello, everybody

In the documentation on the "bind" command under

https://www.tcl.tk/man/tcl8.6/TkCmd/bind.htm#M42

it says at %A: "... Valid only for KeyPress and KeyRelease events."

Since 8.6.9 this substitution is only valid for KeyPress (no longer for KeyRelease); here the documentation should be updated.

The test script

pack [entry .t]
bind .t <KeyRelease> {puts "K: %K, A: %A"}

returns for %A nothing but {}. However, if KeyPress is used (i.e. "bind .t <KeyPress> ..."), the substitution of %A works.

Kind regards

Robert

PS: The change can be found in the Tk sources under unix/tkUnixKey.c in the function TkpGetString(), there under the comment "... Only do this for KeyPress events ..." (line 129).

Francois Vogel

unread,
Jan 27, 2020, 4:30:24 PM1/27/20
to
Thank you for such a high quality report.

The change was made in:

https://core.tcl-lang.org/tk/info/a0f7468229b84dfe

in order to fix ticket:

https://core.tcl-lang.org/tk/info/382712ade6

This patch was engineered by Christian Werner to fix a crash, perhaps he
could have a look?
Should we change the man page or could we allow for KeyRelease in
addition to KeyPress at line 129 of unix/tkUnixKey.c?

Regards,
Francois

undro...@gmail.com

unread,
Jan 28, 2020, 1:13:55 AM1/28/20
to
Am Montag, 27. Januar 2020 22:30:24 UTC+1 schrieb Francois Vogel:
> Le 27/01/2020 à 14:56, Robert Csok a écrit :

Francois, Robert,

> Should we change the man page or could we allow for KeyRelease in
> addition to KeyPress at line 129 of unix/tkUnixKey.c?

given that the normal use case is binding the translated key on <KeyPress>
I'd prefer to change the documentation accordingly and keep the code in
tkUnixKey.c as is.

Use cases where something has to happen on <KeyRelease> are rare and mostly
related to modifiers (Shift/Control/Alt), specific functional keys like
<Return> or <Up> (where the string translation isn't used), or even
unspecific (<KeyRelease> w/o further pattern).

On the AndroWish source tree "fgrep -rl assets" and
"fgrep -rl jni | grep -v '[.][ch]$'" yield:

assets/tksqlite0.5.13/tksqlite.tcl
assets/notebook2.2/lib/gui/searchentry.tcl
assets/tklib0.6/ctext/ctext.tcl
assets/Tkzinc3.3.6/demos/testGraphics.tcl
assets/Tkzinc3.3.6/demos/groupsPriority.tcl
assets/classview0.1/classview.tcl
assets/tkhtml3/hv3-0.1.tm
assets/bwidget1.9.14/dropsite.tcl
assets/bwidget1.9.14/combobox.tcl
assets/iwidgets4.1/combobox.itk
assets/tkbugz/vr_bugz.tcl
assets/tkbugz/tk_bugz.tcl
jni/Tix/PyTix-2.0/2.0/Tkinter.py
jni/SDL2/src/video/winrt/SDL_winrtkeyboard.cpp
jni/snack/demos/tcl/dbrec.tcl
jni/snack/demos/tcl/xs.tcl
jni/tkzinc/Python/demos/testGraphics.py
jni/tkzinc/demos/testGraphics.tcl
jni/tkzinc/demos/groupsPriority.tcl
jni/tkzinc/doc/refman.tex
jni/tkzinc/Perl/demos/Tk/demos/zinc_lib/testGraphics.pl
jni/tkzinc/Perl/demos/Tk/demos/zinc_lib/groups_priority.pl
jni/sdl2tk/ChangeLog
jni/sdl2tk/tests/event.test
jni/sdl2tk/tests/bind.test
jni/sdl2tk/changes
jni/blt/html/hiertable.html
jni/blt/html/treeview.html
jni/blt/html/hierbox.html
jni/blt/library/hierbox.tcl
jni/blt/library/treeview.tcl
jni/blt/library/hiertable.tcl
jni/blt/man/hiertable.mann
jni/blt/man/treeview.mann
jni/blt/man/hierbox.mann
jni/tkhtml/prebuilt/hv3-0.1.tm
jni/tkhtml/hv/hv3_form.tcl

A quick search didn't find a single place where the %A substitution
was used in combination with <KeyRelease>.

Best regards,
Christian

Francois Vogel

unread,
Jan 28, 2020, 2:17:43 AM1/28/20
to
Le 28/01/2020 à 07:13, undro...@gmail.com a écrit :
> given that the normal use case is binding the translated key on <KeyPress>
> I'd prefer to change the documentation accordingly and keep the code in
> tkUnixKey.c as is.

Please let's follow up this discussion in the ticket (I have just
reopened it):

https://core.tcl-lang.org/tk/tktview/382712ade6

Thanks,
Francois
0 new messages