From 5aec9cb96c1d56e4aa44ebe9d623297c36f26cf0 Mon Sep 17 00:00:00 2001 From: wreis Date: Fri, 28 Aug 2009 00:20:19 +0000 Subject: making reaction apply events for buttons defined as type=image --- lib/Reaction/UI/ViewPort.pm | 15 +++++++++------ lib/Reaction/UI/ViewPort/Action.pm | 11 +++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'lib/Reaction') diff --git a/lib/Reaction/UI/ViewPort.pm b/lib/Reaction/UI/ViewPort.pm index ed9722e..7b2898e 100644 --- a/lib/Reaction/UI/ViewPort.pm +++ b/lib/Reaction/UI/ViewPort.pm @@ -97,17 +97,20 @@ sub handle_events { } foreach my $event ($self->accept_events) { if (exists $events->{$event}) { - if (DEBUG_EVENTS) { - my $name = join(' at ', $self, $self->location); - print STDERR - "Applying Event: $event on $name with value: " - .(defined $events->{$event} ? $events->{$event} : '')."\n"; - } + $self->_dump_event($event, $events->{$event}) if DEBUG_EVENTS; $self->$event($events->{$event}); } } } +sub _dump_event { + my ( $self, $name, $value ) = @_; + my $vp_name = join(' at ', $self, $self->location); + print STDERR + "Applying Event: $name on $vp_name with value: " + . (defined $value ? $value : '') . "\n"; +} + sub accept_events { () } sub force_events { () } diff --git a/lib/Reaction/UI/ViewPort/Action.pm b/lib/Reaction/UI/ViewPort/Action.pm index a19f2ca..84b127e 100644 --- a/lib/Reaction/UI/ViewPort/Action.pm +++ b/lib/Reaction/UI/ViewPort/Action.pm @@ -62,6 +62,17 @@ sub sync_action_from_fields { } } +after handle_events => sub { + my ($self, $events) = @_; + foreach my $event ($self->accept_events) { + unless (exists $events->{$event} ) { + # for {"${event}.x"} && exists $events->{"${event}.y"} ) { + $self->$event($events->{$event}); + } + } + } +}; __PACKAGE__->meta->make_immutable; -- cgit v1.2.3-54-g00ecf