callbacks - Online Linux Manual PageSection : 3pm
Updated : 2020-11-09
Source : perl v5.32.0
Note : User Contributed Perl Documentation
NAMETk::callbacks − Specifying code for Tk to call.
SYNOPSISOne can specify a callback in one of the following ways: Without arguments: ... => \&subname, ...
... => sub { ... }, ...
... => 'methodname', ...
or with arguments: ... => [ \&subname, args ... ], ...
... => [ sub { ... }, args... ], ...
... => [ 'methodname', args... ], ...
DESCRIPTIONPerl/Tk has a callback, where Tcl/Tk has a command string (i.e. a fragment of Tcl to be executed). A perl/Tk callback can take one of the following basic forms: • Reference to a subroutine \&subname • Anonymous subroutine (closure) sub { ... } • A method name 'methodname' Any of these can be provided with arguments by enclosing them and the arguments in []. Here are some examples: $mw−>bind($class, ‟<Delete>” => 'Delete'); This will call $widget−>Delete, the $widget being provided (by bind) as the one where the Delete key was pressed. While having bind provide a widget object for you is ideal in many cases it can be irritating in others. Using the list form this behaviour can be modified: $a−>bind(‟<Delete>”,[$b => 'Delete']); because the first element $b is an object bind will call $b−>Delete. Note that method/object ordering only matters for bind callbacks, the auto-quoting in perl5.001 makes the first of these a little more readable: $w−>configure(−yscrollcommand => [ set => $ysb]);
$w−>configure(−yscrollcommand => [ $ysb => 'set' ]);
but both will call $ysb−>set(args provided by Tk) Another use of arguments allows you to write generalized methods which are easier to re-use: $a−>bind("<Next>",['Next','Page']);
$a−>bind("<Down>",['Next','Line']);
This will call $a−>Next('Page') or $a−>Next('Line') respectively. Note that the contents of the [] are evaluated by perl when the callback is created. It is often desirable for the arguments provided to the callback to depend on the details of the event which caused it to be executed. To allow for this callbacks can be nested using the Ev(...) ‟constructor”. Ev(...) inserts callback objects into the argument list. When perl/Tk glue code is preparing the argument list for the callback it is about to call it spots these special objects and recursively applies the callback process to them.
EXAMPLES $entry−>bind('<Return>' => [$w , 'validate', Ev(['get'])]);
$toplevel−>bind('all', '<Visibility>', [\&unobscure, Ev('s')]);
$mw−>bind($class, '<Down>', ['SetCursor', Ev('UpDownLine',1)]);
SEE ALSOTk::bind Tk::after Tk::options Tk::fileevent
KEYWORDScallback, closure, anonymous subroutine, bind 0
Johanes Gumabo
Data Size : 14,738 byte
man-Tk::callbacks.3pmBuild : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 3 / 202,378
Visitor ID : :
Visitor IP : 3.133.149.244 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.
ERROR : Need New Coding : (parse_manual_page_|249|Tk::callbacks.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\|
) (htmlprn|149|Tk::callbacks.3pm|36/37|.el══─{─══. ds -- — |.el══─{─══. ds -- \|\(em\|
) (parse_manual_page_|249|Tk::callbacks.3pm|43|br══─}─══|'br══─}─══
) (htmlprn|149|Tk::callbacks.3pm|43|'br══─}─══ |'br══─}─══
)