Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Ok, this is kind of tricky, but possible. In Tcl, you could do it like this:

bind .t1 <Tab> { focus [tk_focusNext .t1]; break }
So you might think that a straight translation of that would work for Perl/Tk, but it doesn't. (I tried it.)

The reason that a straight translation doesn't work is because Perl/Tk changed the default order that bindtags uses. To change the binding, either subclass and change it, as suggested above, or simply reorder the bindtags for the widget and then you can do the rebind:

# fix the bindtags order so that widget events are # processed before class events $t1->bindtags( [ ($t1->bindtags)[1,0,2,3] ] ); # now give the text widget a new Tab binding $t1->bind( '<Tab>', sub { $t1->focusNext; Tk->break; } );
If you're observant, you'll also notice one other place where it wasn't a straight translation. In Tcl, tk_focusNext just returns the name of the next widget in focus order, then you have to actually call focus on it. In Perl/Tk, it just sets the focus directly.


In reply to Re: re-binding Tab in a TK Text field by kelan
in thread re-binding Tab in a TK Text field by wolfger

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-03-29 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found