Zim::Events.3pm

Langue: en

Version: 2009-03-16 (fedora - 06/07/09)

Section: 3 (Bibliothèques de fonctions)

NAME

Zim::Events - Simple event dispatching

DESCRIPTION

Add a few routines to mimic Gtk style event dispatching for objects that do not inherit from a GObject.

Since we use Perl there is no need to define events types etc. Calling "signal_connect()" will create a new event if the event did not yet exist. Calling "signal_emit()" or "signal_dispatch()" for a non-existing event will be ignored silently.

Although not enforced it is good practise to always emit or dispatch events with the same number of arguments. That way any code connecting with extra DATA arguments can function properly without to much hassle. Handlers are called like object methods with a reference to the object as first argument.

METHODS

"signal_connect(NAME, CODE, @DATA)"
Connect a handler for a signal. CODE will be called when either "signal_emit()" or "signal_dispatch()" is called. DATA are arguments that will be passed to the handler after the default arguments for this signal.
"signal_emit(NAME, @ARGS)"
Call all handlers that are conneccted to this signal. Returns a list with return values. ARGS are passed to the handler routines.
"signal_dispatch(NAME, @ARGS)"
Like "signal_emit()", but stops after the first handler that does not return FALSE and returns that value. Used for example for GUI actions that can be overloaded from a plugin by connecting a like named signal.

This method does not have a Gtk equivalent; in Gtk the event accumulator type is used to get this behavior for certain events. Reason to have this method instead of an event property is that we do not want to predefine all GUI actions as events. And neither do we want plugins to do this for each signal they overload. By determining this behavior at call time for signals that may or may not exist we keep things simple and Perlish.

AUTHOR

Jaap Karssenberg (Pardus) <pardus@cpan.org>

Copyright (c) 2006, 2008 Jaap G Karssenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Zim