X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FReaction%2FUI%2FViewPort.pm;h=06ffffa864dec525ba4a8bd40a3af6be106bc896;hb=e653a48785a1942da650254c8fba30706ca18333;hp=5e6f39c06d7f743d9099fb76c777356accca85cd;hpb=8b55efe277d06027502f9d6b9727c8e584ef708e;p=catagits%2FReaction.git diff --git a/lib/Reaction/UI/ViewPort.pm b/lib/Reaction/UI/ViewPort.pm index 5e6f39c..06ffffa 100644 --- a/lib/Reaction/UI/ViewPort.pm +++ b/lib/Reaction/UI/ViewPort.pm @@ -68,25 +68,23 @@ sub apply_child_events { foreach my $child ($self->child_event_sinks) { confess blessed($child) ."($child) is not a valid object" unless blessed($child) && $child->can('apply_events'); - $child->apply_events($events); + my $loc = $child->location; + my %child_events = map { $_ => delete $events->{$_} } + grep { /^${loc}[-:]/ } keys %$events; + $child->apply_events(\%child_events); } } sub apply_our_events { my ($self, $events) = @_; - my @keys = keys %$events; - return unless @keys; my $loc = $self->location; my %our_events; foreach my $key (keys %$events) { if ($key =~ m/^${loc}:(.*)$/) { - $our_events{$1} = $events->{$key}; + $our_events{$1} = delete $events->{$key}; } } - if (keys %our_events) { - #warn "$self: events ".join(', ', %our_events)."\n"; - $self->handle_events(\%our_events); - } + $self->handle_events(\%our_events) if keys %our_events; } sub handle_events { @@ -103,7 +101,7 @@ sub handle_events { my $name = join(' at ', $self, $self->location); print STDERR "Applying Event: $event on $name with value: " - .(defined $events->{$event} ? $events->{$event} : ''); + .(defined $events->{$event} ? $events->{$event} : '')."\n"; } $self->$event($events->{$event}); } @@ -121,14 +119,12 @@ sub event_id_for { sub sort_by_spec { my ($self, $spec, $items) = @_; - return $items if not defined $spec; + return [sort @$items] unless $spec; my @order; if (ref $spec eq 'ARRAY') { @order = @$spec; - } - elsif (not ref $spec) { - return $items unless length $spec; + } elsif (not ref $spec) { @order = split /\s+/, $spec; }