diff options
author | wreis <wreis@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7> | 2009-08-28 00:20:19 +0000 |
---|---|---|
committer | wreis <wreis@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7> | 2009-08-28 00:20:19 +0000 |
commit | 5aec9cb96c1d56e4aa44ebe9d623297c36f26cf0 (patch) | |
tree | 1ef2169e6531db86d8c2cc18566a016ee646ba9a | |
parent | 7d742f8a0b38d58cbec5ece738c3bdf1873ddfb4 (diff) | |
download | reaction-5aec9cb96c1d56e4aa44ebe9d623297c36f26cf0.tar.gz reaction-5aec9cb96c1d56e4aa44ebe9d623297c36f26cf0.zip |
making reaction apply events for buttons defined as type=image
-rw-r--r-- | lib/Reaction/UI/ViewPort.pm | 15 | ||||
-rw-r--r-- | lib/Reaction/UI/ViewPort/Action.pm | 11 |
2 files changed, 20 insertions, 6 deletions
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} : '<undef>')."\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 : '<undef>') . "\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 <input type="image"... buttons + if ( exists $events->{"${event}.x"} && exists $events->{"${event}.y"} ) { + $self->$event($events->{$event}); + } + } + } +}; __PACKAGE__->meta->make_immutable; |