1#!/usr/local/bin/perl -w
2
3use Tk;
4use Tk::Table;
5use Tk::Entry;
6
7sub Foo::new {
8    return bless {}
9}
10
11
12$MAX_ITEMS = 10;
13$VIEWED_ITEMS = 5;
14
15$f = new Foo;  # Used later for callback setup.
16
17$top = new MainWindow();
18
19my $t  = $top->Table(-scrollbars => 'e',
20		      -rows => $VIEWED_ITEMS,
21		      -columns => 3,
22		      -highlightthickness => 0,
23		      );
24$t->pack(-expand => 1,
25	 -fill => 'both'
26	 );
27
28### Set up the entries and bindings.
29
30foreach $r (0..$MAX_ITEMS-1) {
31    $c = 0;
32    $tmp = ["0,$r","1,$r","2,$r"];
33    foreach (@$tmp) {
34	$e = $t->Entry(-width => 5,
35		       -relief => 'sunken',
36		       -highlightthickness => 0,
37		       -borderwidth => 1,
38		       -textvariable => \$_);
39	$t->put($r, $c++, $e);
40    }
41
42    $t->get($r, 0)->bind('<Return>' => [$f, 'recalc', $r]);
43    $t->get($r, 1)->bind('<Return>' => [$f, 'find', $r]);
44}
45
46MainLoop();
47exit;
48
49sub recalc {
50    my($self, $r) = @_;
51
52    print STDERR "In recalc on row $r\n";
53
54    my $w = $t->get($r,1);
55    $w->focus() ;
56}
57
58
59sub find {
60    my($self, $r) = @_;
61
62    print STDERR "In find on row $r\n";
63
64    if (1 && $r < $MAX_ITEMS) {
65	my $w = $t->get($r+1,0);
66	$w->focus() ;
67	$t->see($w);
68    }
69}
70__END__
71
72