in reply to Re: Tk preventing a char in Entry widged to trigger a KeyBinding
in thread Tk preventing a char in Entry widged to trigger a KeyBinding

It still prints the message when I press ? inside the entry. The following works for me, though:
#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = MainWindow->new->geometry("100x100+799+336"); my $entry = $mw->Entry( -text => '', -width => 20 )->pack(); $entry->bind('<KeyRelease-question>' => sub { Tk->break }); $mw->bind( '<KeyRelease-question>' => sub { print "? was pressed!\n" + }); $mw->Entry->pack; MainLoop();

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^3: Tk preventing a char in Entry widged to trigger a KeyBinding
by Discipulus (Canon) on Oct 12, 2016 at 07:38 UTC
    Thanks choroba,

    your example works correctly, or well, it works as I desire. But this imply to collect all entries as named instances, ie my $entry_first = $mw->Entry... my $entry_second = $mw->Entry

    It is too much work for me! maybe i'll try to bind all Tk::Entry class to Tk->break for all my defined bindings.

    I was not aware of the possibility to bind to an entire class, nor about Tk->break

    Incidentally my $mw = MainWindow->new->geometry("100x100+799+336"); gives me an undefined value at line 9. On my Tk version i needed a more verbose statement my $mw = MainWindow->new(); $mw->geometry("100x100+799+336");

    L*

    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.
        eheh wait, named monks have the priority! ;=) see below

        L*

        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.
Re^3: Tk preventing a char in Entry widged to trigger a KeyBinding
by tybalt89 (Monsignor) on Oct 11, 2016 at 22:25 UTC

    Interesting - it doesn't print the message for me when the cursor is in the entry field.