Re: A problem to add binding to entry widget
> Fred Xia writes
>
> There is a problem in add a binding to the entry for the <KeyPress> event.
> I use the add-binding routine suggested by the author as below:
>
>
> Say I have a entry widget .a and I added a bind as:
>
> (add-binding '.a "<KeyPress>" '(format #t "AAA") :after)
>
> The binding is fine except key '\'. When I type '\', stk gives me error
> of "end of file inside list". However, without adding the binding, key
> '\' is as normal as any other keys.
This works fine for me with the example you give. However, you could have
problem with characters '\' and '"' if you use the %A in a string with the
body of a binding. For instance
(add-binding '.a "<Any-Key>"
'(format #t "\nYou have typed %A") :after)
will have a problem with those chars, since substitution is done by Tk before
giving the binding to Scheme for evaluation. In particular, if you type
a '\' the binding will be
(format #t "\nYou have typed \")
which is incorrect. A solution, for now, would be to add a binding
for <Key-quotedbl> and <Key-backslash>.
Have a look in Lib/entry.stk; you will see that those chars are managed
specially.
Hope this helps.
-- Erick
Received on Wed Apr 26 1995 - 09:23:27 CEST
This archive was generated by hypermail 2.3.0
: Mon Jul 21 2014 - 19:38:59 CEST