Tk::SignalSlot - An alternative to Tk::bind
use Tk::SignalSlot; $w->connect('<1>' => \&callback1); $w->connect('<1>' => \&callback2); my $id = $w->connect('<<Event>>' => \&callback3); ... $w->disconnect($id) if $w->is_connected($id);
Tk::SignalSlot provides an alternative to Tk::bind that is more similar to Qt's signal/slot mechanism. The main idea is that multiple callbacks can now be bound to one event. This allows for a more modular and object-oriented approach to Tk::bind which results in simpler, and easier to maintain code.
Please see "RESTRICTIONS" for some important information.
Tk::SingalSlot exports three new methods into the Tk:: namespace:
This method connects the given callback to the event. This means that when the event is triggered, this callback will be executed. Any number of callbacks can be connected to any one event. When the event fires, all connected callbacks will execute in the order they were connected. event is any valid Tk event, and callback is any valid Tk callback.
Upon success, this method returns a unique ID that can be used in the disconnect() method below.
Given a valid ID (returned by the connect() method), this method disconnects the associated callback from the event. Obviously, this means that when the event fires, this callback will not be executed.
Returns 1 if the given ID is that of a validly connected callback. Otherwise, returns 0;
If you decide to use Tk::SignalSlot, then you should stick with it thoroughtout your program. Intermixing Tk::SignalSlot with Tk::bind can have some unpredictable effects since Tk::SignalSlot uses Tk::bind internally.
None so far.
Ala Qumsieh <email@example.com>
Copyright (c) 2006 Ala Qumsieh. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.