diff options
author | Maarten Vanraes <alien@mageia.org> | 2016-01-09 16:59:28 +0100 |
---|---|---|
committer | Maarten Vanraes <alien@mageia.org> | 2016-01-09 16:59:28 +0100 |
commit | 5257d946c84c1ea5d4b77cf904aa21e4a427e904 (patch) | |
tree | 63da9cb585d77ba81ef29edeff5fe8a98cfa275f /lib/ManaTools/Shared | |
parent | 3f9f4ab039bc7b3892a5683143ace4e183211c26 (diff) | |
download | manatools-5257d946c84c1ea5d4b77cf904aa21e4a427e904.tar manatools-5257d946c84c1ea5d4b77cf904aa21e4a427e904.tar.gz manatools-5257d946c84c1ea5d4b77cf904aa21e4a427e904.tar.bz2 manatools-5257d946c84c1ea5d4b77cf904aa21e4a427e904.tar.xz manatools-5257d946c84c1ea5d4b77cf904aa21e4a427e904.zip |
add parent link to EventHandlerRole move parentDialog
Diffstat (limited to 'lib/ManaTools/Shared')
-rw-r--r-- | lib/ManaTools/Shared/GUI/EventHandlerRole.pm | 31 | ||||
-rw-r--r-- | lib/ManaTools/Shared/GUI/EventRole.pm | 23 | ||||
-rw-r--r-- | lib/ManaTools/Shared/GUI/ExtTab.pm | 7 |
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(); |