Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.

Quick

  • ($a, $b....) = unpack("A2A7...", $packed)
  • push( array, list )

Thursday, March 8, 2012

Perl::Tk tabbing

This is the encapsulation I've been using to fix the incredibly annoying broken tabbing feature on Tk Text boxes. NB it doesn't work on multiline Texts but then I've not so far wanted tab-to-next field behaviour on those.

sub enable_tab {
my ($control, $nextcontrol) = @_;
# NB closure below - when the code runs, $control and $nextcontrol will have
# the values they do in this context here.
$control->bind("<Tab>" =>
sub {
$nextcontrol->focus();
$control->break();
} );
# make sure our new binding has priority
my @tags = $control->bindtags;
($tags[0], $tags[1]) = ($tags[1], $tags[0]);
$control->bindtags([@tags]);
}


I call it when I've created and packed my Texts:

enable_tab($textcontrol, $control_to_tab_to);

Followers

Blog Archive