aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ManaTools/Shared
diff options
context:
space:
mode:
authorMaarten Vanraes <alien@mageia.org>2016-01-09 14:02:34 +0100
committerMaarten Vanraes <alien@mageia.org>2016-01-09 14:02:34 +0100
commit817de92555ee6a3dc1675fd559bbb3247a8f2356 (patch)
treec957b55e7358ae2cab2131a908beb7dc6e83f7db /lib/ManaTools/Shared
parent3dc6d2e47c455bf0c286c6f5cbf002f29ddf696d (diff)
downloadmanatools-817de92555ee6a3dc1675fd559bbb3247a8f2356.tar
manatools-817de92555ee6a3dc1675fd559bbb3247a8f2356.tar.gz
manatools-817de92555ee6a3dc1675fd559bbb3247a8f2356.tar.bz2
manatools-817de92555ee6a3dc1675fd559bbb3247a8f2356.tar.xz
manatools-817de92555ee6a3dc1675fd559bbb3247a8f2356.zip
EventHandlerRole: add item helper functions (MenuEvent)
Diffstat (limited to 'lib/ManaTools/Shared')
-rw-r--r--lib/ManaTools/Shared/GUI/EventHandlerRole.pm105
1 files changed, 105 insertions, 0 deletions
diff --git a/lib/ManaTools/Shared/GUI/EventHandlerRole.pm b/lib/ManaTools/Shared/GUI/EventHandlerRole.pm
index fd785cba..532ca3b5 100644
--- a/lib/ManaTools/Shared/GUI/EventHandlerRole.pm
+++ b/lib/ManaTools/Shared/GUI/EventHandlerRole.pm
@@ -337,6 +337,111 @@ sub findWidget {
#=============================================================
+=head2 addItem
+
+=head3 INPUT
+
+ $self: this object
+ $name: a name to identify the item
+ $item: a yui item
+ $event: an optional CodeRef that will be executed when an Event triggers
+ $backend: an optional backend object that will be present in the event handler
+
+=head3 DESCRIPTION
+
+ add a item event handler to the events list
+
+=cut
+
+#=============================================================
+sub addItem {
+ my $self = shift;
+ my $name = shift;
+ my $item = shift;
+ my $event = shift;
+ my $backend = shift;
+ return ManaTools::Shared::GUI::Event->new(name => $name, eventHandler => $self, eventType => $yui::YEvent::MenuEvent, item => $item, event => $event, backend => $backend);
+}
+
+#=============================================================
+
+=head2 delItem
+
+=head3 INPUT
+
+ $self: this object
+ $item: a yui item
+
+=head3 DESCRIPTION
+
+ del a item event handler from the events list
+
+=cut
+
+#=============================================================
+sub delItem {
+ my $self = shift;
+ my $item = shift;
+ my $event = $self->findItem($item);
+ $self->delEvent($event->name()) if (defined $event);
+}
+
+#=============================================================
+
+=head2 item
+
+=head3 INPUT
+
+ $self: this object
+ $name: the item identified by $name
+
+=head3 DESCRIPTION
+
+ returns a yui::YItem
+
+=cut
+
+#=============================================================
+sub item {
+ my $self = shift;
+ my $name = shift;
+ return undef if (!$self->hasEvent($name));
+ my $event = $self->getEvent($name);
+ return undef if ($event->eventType() != $yui::YEvent::MenuEvent);
+ return undef if (!$event->isa('ManaTools::Shared::GUI::Event'));
+ return $event->item();
+}
+
+#=============================================================
+
+=head2 findItem
+
+=head3 INPUT
+
+ $self: this object
+ $item: the yui::YItem to be found
+
+=head3 DESCRIPTION
+
+ returns a ManaTools::Shared::GUI::Dialog::Event that has the item
+
+=cut
+
+#=============================================================
+sub findItem {
+ my $self = shift;
+ my $item = shift;
+ return $self->findEvent(sub {
+ my $event = shift;
+ my $item = shift;
+ return 0 if ($event->eventType() != $yui::YEvent::MenuEvent);
+ return 0 if (!$event->isa('ManaTools::Shared::GUI::Event'));
+ return $event->equalsItem($item);
+ }, $item);
+}
+
+#=============================================================
+
=head2 processEvents
=head3 INPUT