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.
-
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.