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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.