SignalSlot(3) User Contributed Perl Documentation SignalSlot(3) NNNNAAAAMMMMEEEE Tk::SignalSlot - An alternative to Tk::bind SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS use Tk::SignalSlot; $w->connect(’<1>’ => \&callback1); $w->connect(’<1>’ => \&callback2); my $id = $w->connect(’<>’ => \&callback3); ... $w->disconnect($id) if $w->is_connected($id); DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN TTTTkkkk::::::::SSSSiiiiggggnnnnaaaallllSSSSllllooootttt 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 eas- ier to maintain code. Please see the section on "RESTRICTIONS" for some important informa- tion. MMMMEEEETTTTHHHHOOOODDDDSSSS TTTTkkkk::::::::SSSSiiiinnnnggggaaaallllSSSSllllooootttt exports three new methods into the TTTTkkkk:::::::: namespace: _$_w_i_d_g_e_t->ccccoooonnnnnnnneeeecccctttt(_e_v_e_n_t, _c_a_l_l_b_a_c_k) 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. _e_v_e_n_t is any valid Tk event, and _c_a_l_l_b_a_c_k is any valid Tk callback. Upon success, this method returns a unique ID that can be used in the _dd_ii_ss_cc_oo_nn_nn_ee_cc_tt_((_)) method below. _$_w_i_d_g_e_t->ddddiiiissssccccoooonnnnnnnneeeecccctttt(_I_D); Given a valid ID (returned by the _cc_oo_nn_nn_ee_cc_tt_((_)) mmmmeeeetttthhhhoooodddd), this method disconnects the associated callback from the event. Obviously, this means that when the event fires, this callback will not be executed. _$_w_i_d_g_e_t->iiiissss____ccccoooonnnnnnnneeeecccctttteeeedddd(_I_D); Returns 1 if the given ID is that of a validly connected callback. Otherwise, returns 0; RRRREEEESSSSTTTTRRRRIIIICCCCTTTTIIIIOOOONNNNSSSS If you decide to use TTTTkkkk::::::::SSSSiiiiggggnnnnaaaallllSSSSllllooootttt, then you should stick with it thoroughtout your program. Intermixing TTTTkkkk::::::::SSSSiiiiggggnnnnaaaallllSSSSllllooootttt with TTTTkkkk::::::::bbbbiiiinnnndddd can have some unpredictable effects since TTTTkkkk::::::::SSSSiiiiggggnnnnaaaallllSSSSllllooootttt uses TTTTkkkk::::::::bbbbiiiinnnndddd internally. BBBBUUUUGGGGSSSS None so far. AAAAUUUUTTTTHHHHOOOORRRR AAAAllllaaaa QQQQuuuummmmssssiiiieeeehhhh CCCCOOOOPPPPYYYYRRRRIIIIGGGGHHHHTTTT 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. 3rd Berkeley Distribution perl v5.6.1 SignalSlot(3)