#!/usr/bin/perl -w

use Tk;
use strict;

my ($main, @tags);

$main = MainWindow->new();
$main->{l1} = $main->Label(-text=>"Name: ");
$main->{l2} = $main->Label(-text=>"Phone: ");
$main->{name} = $main->Entry;
$main->{phone} = $main->Entry;
$main->{l1}->pack($main->{name}, $main->{l2}, $main->{phone},
    -side=>"left", -fill=>"both");

@tags = $main->{phone}->bindtags;
print "@tags\n";
$main->{phone}->bindtags(["filter", @tags]);
$main->{phone}->bind("filter", "<Control-Key>", sub {});
$main->{phone}->bind("filter", "<Key>", [\&check_phone_key, Ev('K')]);

MainLoop();

sub check_phone_key {
    my ($w, $key) = @_;
    foreach (qw(BackSpace Tab Left Right Control_L Control_R)) {
	return if $key eq $_;
    }
    return if ($key =~ /[0-9-]/ or $key eq "minus");
    $w->bell;
    $w->break;
};

