Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Tk preventing a char in Entry widged to trigger a KeyBinding

by choroba (Cardinal)
on Oct 11, 2016 at 22:01 UTC ( [id://1173775]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1173775]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-26 02:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found