Leser: 1
5 Einträge, 1 Seite |
1 2 3 4 5 6 7 8
#!/usr/bin/perl use strict; use warnings; use module::Main; die print "Programmfehler!" unless Main::Run();
1 2 3 4 5 6 7 8 9 10 11 12 13 14
package Main; use strict; use warnings; use module::Config; our $Config = new Config; sub Run { return -1 unless $Config->Start(); return 1; }
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
package Config; use strict; use warnings; use Tk; use module::Navi; sub new { my ($this) = @_; bless my $self = {} => (ref $this) || $this; $self->{mw} = new MainWindow; my $fr1 = $self->{mw}->Frame->pack; return undef unless $self->{Navi} = new Navi($fr1); $self->{Navi}->SetCallBackEvent(\&ViewEvent); } sub Start { MainLoop(); } sub ViewEvent { my($this) = @_; # !!! $this - Kein Objekt. Hä ??? }
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
package Navi; use strict; use warnings; use Tk::Tree; my $EventHandler = undef; sub new { my($this, $top) = @_; bless my $self = {} => (ref $this) || $this; $self->{tree} = $top->Scrolled ( qw/Tree/ ) ->pack; $self->{tree}->bind('<ButtonPress-1>', [ \&TreeEvent ]); $self->{tree}->bind('<KeyPress>' , [ \&TreeEvent ]); # # Hier Tree befüllen # $self->{tree}->autosetmode; } sub TreeEvent { my($this) = @_; # !!! Nicht Objekt, sondern Tree=HASH(...) ??? return unless my $sl = $this->info('selection'); &$EventHandler($this->info('data', $sl)); } sub SetCallBackEvent { my($this, $event) = @_; # Hier $this - o.k. $EventHandler = $event; }
QuoteMain::Run();
module::Main::Run();
return unless ...
package module::Main;
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
package activ_db::Config; # ... wie gehabt # hier Zeiger auf das Objekt - muss das wirklich sein :( my $Me = undef; sub new { my ($class) = @_; $Me = bless({}, $class); # Rest wie gehabt ... } sub ViewEvent { my($view) = @_; # Hier kein Objekt ! if($view == 1001) # $view ist korrekt (gibt immer eine zahl) { # keine $self in der sub :( $Me->{Daten} = new activ_db::DatenControl($Me->{daten_frame}) unless ($Me->{Daten}); } }
1 2 3 4 5 6 7
sub TreeEvent { my($tree) = @_; return unless my $sl = $tree->info('selection'); &$EventHandler($tree->info('data', $sl)) if $EventHandler; }
5 Einträge, 1 Seite |