Hello, I'm facing a small but annoying problem in my Tk code: some control keys - like ctl-s - keep inserting sequences of characters - like \x{13} - in a Text field of my Notebook tab provided that the insertion point is located in this field when the key is pressed. The bindings for this Text field can be reordered, it doesn't change this, for example I have a main window binding for <Control-s> that is inhibited by the following Text widget binding, the unwanted \x{13} appears nevertheless:
$mw->bind($mw, "<Control-s>" => sub { print "not printed\n" } ); my $Notes_tw = $Tabs{'Notes'}->Scrolled( 'TextUndo' , -background=>$COLOR{input_bgcolor} , -foreground =>$COLOR{input_fgcolor} , -scrollbars => 'se' , -wrap => 'word' ); $Notes_tw->bind("<Control-s>", \&handlectl); sub handlectl { my @tags = $Notes_tw->bindtags; print ' typefield=', $Tk::event->T,"\n", ' winfield=', $Tk::event->i,"\n", ' widgetfield=', $Tk::event->W,"\n", ' xrootfield=', $Tk::event->X,"\n", ' yrootfield=', $Tk::event->Y,"\n", ' sendfield=', $Tk::event->E,"\n", ' state=', $Tk::event->s,"\n", ' unicode=', $Tk::event->A,"\n", ' KeySym=', $Tk::event->K,"\n", ' numeric=', $Tk::event->N,"\n", ' keycode=', $Tk::event->k,"\n", "tags=@tags\n"; Tk->break; }
program output:
typefield=KeyPress
winfield=
widgetfield=Tk::TextUndo=HASH(0x2909c78)
xrootfield=1115
yrootfield=558
sendfield=0
state=Control-Mod2-
unicode=
KeySym=s
numeric=115
keycode=39
tags=Tk::Frame .notebook.notes.frame1 . all Freeze
The main window binding is well inhibited by the Tk->break, but no matter if I change the tags order with:
$Notes_tw->bindtags([$Notes_tw,$Notes_tw->toplevel,'all',ref($Notes_tw)]); # for example...
the Notes_tw field will keep displaying a \x{13} each time I press <Control-s>.
What can I do to get rid of this?
P.S.
This problem is specially embarrassing to me because if I save my config with ctl-s when located in my Notes field, then the content of this field is copied in my config file which in turn will get loaded at next launch and parsed by XML.pm. However XML.pm aborts when meeting \x{13}. I can easily forget that I'm within a Text field when saving my job.
In reply to Tk hidden binding by emilbarton
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |