File: al_bug

package info (click to toggle)
perl-tk 1:800.025-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 18,444 kB
  • ctags: 19,081
  • sloc: ansic: 206,740; perl: 40,187; makefile: 4,371; sh: 2,373; yacc: 762
file content (71 lines) | stat: -rwxr-xr-x 1,191 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/local/bin/nperl -w

use Tk;
use Tk::Table;
use Tk::Entry;

sub Foo::new {
    return bless {}
}


$MAX_ITEMS = 10;   
$VIEWED_ITEMS = 5;

$f = new Foo;  # Used later for callback setup.

$top = new MainWindow();

my $t  = $top->Table(-scrollbars => 'e',
		      -rows => $VIEWED_ITEMS,
		      -columns => 3,
		      -highlightthickness => 0,
		      );
$t->pack(-expand => 1, 
	 -fill => 'both'
	 );

### Set up the entries and bindings.

foreach $r (0..$MAX_ITEMS-1) {
    $c = 0;
    $tmp = ["0,$r","1,$r","2,$r"];
    foreach (@$tmp) {
	$e = $t->Entry(-width => 5, 
		       -relief => 'sunken',
		       -highlightthickness => 0,
		       -borderwidth => 1,
		       -textvariable => \$_);
	$t->put($r, $c++, $e);	
    } 
    
    $t->get($r, 0)->bind('<Return>' => [$f, 'recalc', $r]);
    $t->get($r, 1)->bind('<Return>' => [$f, 'find', $r]);
}

MainLoop();
exit; 

sub recalc {
    my($self, $r) = @_;

    print STDERR "In recalc on row $r\n";

    my $w = $t->get($r,1);
    $w->focus() ;
}


sub find {
    my($self, $r) = @_;

    print STDERR "In find on row $r\n";

    if (1 && $r < $MAX_ITEMS) {
	my $w = $t->get($r+1,0);
	$w->focus() ;
	$t->see($w);
    }
}
__END__