aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/ManaTools/Shared/GUI/EventHandlerRole.pm31
-rw-r--r--lib/ManaTools/Shared/GUI/EventRole.pm23
-rw-r--r--lib/ManaTools/Shared/GUI/ExtTab.pm7
3 files changed, 39 insertions, 22 deletions
diff --git a/lib/ManaTools/Shared/GUI/EventHandlerRole.pm b/lib/ManaTools/Shared/GUI/EventHandlerRole.pm
index e01f5c89..289267fb 100644
--- a/lib/ManaTools/Shared/GUI/EventHandlerRole.pm
+++ b/lib/ManaTools/Shared/GUI/EventHandlerRole.pm
@@ -65,6 +65,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
use Moose::Role;
+has 'parentEventHandler' => (
+ is => 'rw',
+ isa => 'Maybe[ManaTools::Shared::GUI::EventHandlerRole]',
+ default => undef,
+);
+
has 'eventHandlers' => (
is => 'ro',
isa => 'ArrayRef[ManaTools::Shared::GUI::EventHandlerRole]',
@@ -103,6 +109,7 @@ sub addEventHandler {
my $eventHandler = shift;
my $eventHandlers = $self->eventHandlers();
push @{$eventHandlers}, $eventHandler;
+ $eventHandler->parentEventHandler($self);
}
#=============================================================
@@ -129,6 +136,7 @@ sub delEventHandler {
while ($i > 0) {
$i = $i - 1;
if ($eventHandlers->[$i] == $eventHandler) {
+ $eventHandler->parentEventHandler(undef);
# splice the eventHandler out of it
splice @{$eventHandlers}, $i, 1;
return ;
@@ -546,5 +554,28 @@ sub processEvents {
#=============================================================
+=head2 parentDialog
+
+=head3 INPUT
+
+ $self: this object
+
+=head3 DESCRIPTION
+
+ finds the parent Dialog
+
+=cut
+
+#=============================================================
+sub parentDialog {
+ my $self = shift;
+ return $self if $self->isa('ManaTools::Shared::GUI::Dialog');
+ my $eventHandler = $self->parentEventHandler();
+ return $eventHandler->parentDialog() if defined $eventHandler;
+ return undef;
+}
+
+#=============================================================
+
1;
diff --git a/lib/ManaTools/Shared/GUI/EventRole.pm b/lib/ManaTools/Shared/GUI/EventRole.pm
index 02376b81..3326610b 100644
--- a/lib/ManaTools/Shared/GUI/EventRole.pm
+++ b/lib/ManaTools/Shared/GUI/EventRole.pm
@@ -75,6 +75,7 @@ has 'eventHandler' => (
is => 'ro',
does => 'ManaTools::Shared::GUI::EventHandlerRole',
required => 1,
+ handles => [ 'parentDialog' ],
);
has 'name' => (
@@ -107,27 +108,5 @@ sub DEMOLISH {
#=============================================================
-=head2 parentDialog
-
-=head3 INPUT
-
- $self: this object
-
-=head3 DESCRIPTION
-
- finds the parent Dialog
-
-=cut
-
-#=============================================================
-sub parentDialog {
- my $self = shift;
- my $eventHandler = $self->eventHandler();
- while (defined($eventHandler) && !$eventHandler->isa('ManaTools::Shared::GUI::Dialog') && $eventHandler->does('ManaTools::Shared::GUI::EventRole')) {
- $eventHandler = $eventHandler->eventHandler();
- }
- return $eventHandler;
-}
-
1;
diff --git a/lib/ManaTools/Shared/GUI/ExtTab.pm b/lib/ManaTools/Shared/GUI/ExtTab.pm
index 46acb7f2..863e09b8 100644
--- a/lib/ManaTools/Shared/GUI/ExtTab.pm
+++ b/lib/ManaTools/Shared/GUI/ExtTab.pm
@@ -81,6 +81,7 @@ use utf8;
with 'ManaTools::Shared::GUI::EventRole';
use yui;
+use ManaTools::Shared::GUI::ReplacePoint;
#=============================================================
@@ -195,6 +196,12 @@ sub buildTab {
# create a replacepoint on the tab
$self->{replacepoint} = ManaTools::Shared::GUI::ReplacePoint->new(parentWidget => $tab);
+
+ # parentEventHandler must be set directly, because we don't add the
+ # eventHandler to a parentEventHandler, instead the events are processed
+ # through the Tab's EventRole processEvent function
+ $self->{replacepoint}->parentEventHandler($self->{eventHandler});
+
# don't add any children right away
$self->{replacepoint}->finished();