From 3c0aaf37d6c56708293b493524a7465668b0b0a6 Mon Sep 17 00:00:00 2001 From: Angelo Naselli Date: Fri, 1 Jan 2016 20:03:36 +0100 Subject: delWidget needs event name not event changed processEvents to manage event deletion during event managing --- lib/ManaTools/Shared/GUI/Event.pm | 8 ++++---- lib/ManaTools/Shared/GUI/EventHandlerRole.pm | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'lib/ManaTools/Shared') diff --git a/lib/ManaTools/Shared/GUI/Event.pm b/lib/ManaTools/Shared/GUI/Event.pm index f9793a7f..655adffb 100644 --- a/lib/ManaTools/Shared/GUI/Event.pm +++ b/lib/ManaTools/Shared/GUI/Event.pm @@ -133,12 +133,12 @@ has 'backend' => ( sub processEvent { my $self = shift; my $yevent = shift; - return 1 if ($yevent->eventType != $self->eventType); - return 1 if ($yevent->eventType == $yui::YEvent::WidgetEvent && !$self->equalsWidget($yevent->widget)); - return 1 if ($yevent->eventType == $yui::YEvent::MenuEvent && !$self->equalsItem($yevent->item)); + return -1 if ($yevent->eventType != $self->eventType); + return -1 if ($yevent->eventType == $yui::YEvent::WidgetEvent && !$self->equalsWidget($yevent->widget)); + return -1 if ($yevent->eventType == $yui::YEvent::MenuEvent && !$self->equalsItem($yevent->item)); my $event = $self->event(); return $event->($self, $yevent, $self->backend()) if defined($event); - return 1; + return -1; } sub equalsWidget { diff --git a/lib/ManaTools/Shared/GUI/EventHandlerRole.pm b/lib/ManaTools/Shared/GUI/EventHandlerRole.pm index 83db71b3..fd785cba 100644 --- a/lib/ManaTools/Shared/GUI/EventHandlerRole.pm +++ b/lib/ManaTools/Shared/GUI/EventHandlerRole.pm @@ -278,7 +278,7 @@ sub delWidget { my $self = shift; my $widget = shift; my $event = $self->findWidget($widget); - $self->delEvent($event) if (defined $event); + $self->delEvent($event->name()) if (defined $event); } #============================================================= @@ -361,7 +361,8 @@ sub processEvents { my $events = $self->events(); # loop all the items for my $event (values %{$events}) { - return 0 if(!$event->processEvent($yevent)); + my $processed = $event->processEvent($yevent); + return $processed if $processed >= 0; } return 1; } -- cgit v1.2.1