Hello monks,

I never considered this behaviour that even if logical seems annoying, at least to me. If i have an Entry widged and I enter there a character that is bound to a callback, the callback is called.

Consider the following example:

#!/usr/bin/perl use warnings; use strict; use Tk; # use Tk::WidgetDump; # use Tk::ObjScanner; my $mw = MainWindow->new(); $mw->geometry("100x100"); $mw->Entry( -text => '',-width => 20)->pack(); $mw->bind('<KeyRelease-?>' => sub{print "A question mark was pressed!! +\n"} ); # $mw->WidgetDump(); MainLoop;

When you enter in the Entry widget a question mark the anonymous sub is called. This is a very undesired beahviour for an application with potentially many Entry widgets and potentially many keybindings.

I think I can workaround this putting all Entry in an array @all_text_entries and manually iterating over them to clear all bindings esplicitly set by my application. Even if possible this seems very boring and possibly not so easy to maintain.

Uncomment the Tk::WidgetDump Tk::ObjScanner imports and the $mw->WidgetDump(); to see a very useful dump of all stuffs and bindings too.

Ideas?

L*

PS: sorry for my english that becomes worst due to sleep privation. What i intended to says is: it is possible to disable a keybinding to run it's associated sub if the bound key is entered into an Entry widget?

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

In reply to Tk preventing a char in Entry widged to trigger a KeyBinding by Discipulus

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.