home *** CD-ROM | disk | FTP | other *** search
-
- <HTML>
- <HEAD>
- <TITLE>Tk::after - Execute a command after a time delay</TITLE>
- <LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
- <LINK REV="made" HREF="mailto:">
- </HEAD>
-
- <BODY>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> Tk::after - Execute a command after a time delay</P></STRONG>
- </TD></TR>
- </TABLE>
-
- <A NAME="__index__"></A>
- <!-- INDEX BEGIN -->
-
- <UL>
-
- <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
-
- <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
- <LI><A HREF="#description">DESCRIPTION</A></LI>
- <LI><A HREF="#see also">SEE ALSO</A></LI>
- <LI><A HREF="#keywords">KEYWORDS</A></LI>
- </UL>
- <!-- INDEX END -->
-
- <HR>
- <P>
- <H1><A NAME="name">NAME</A></H1>
- <P>Tk::after - Execute a command after a time delay</P>
- <P>
- <HR>
- <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
- <UL>
- <LI>Linux</LI>
- <LI>Solaris</LI>
- <LI>Windows</LI>
- </UL>
- <HR>
- <H1><A NAME="synopsis">SYNOPSIS</A></H1>
- <P> <EM>$widget</EM>-><STRONG>after</STRONG>(<EM>ms</EM>)</P>
- <P> <EM>$id</EM> = <EM>$widget</EM>-><STRONG>after</STRONG>(<EM>ms</EM>?,<EM>callback</EM>?)</P>
- <P> <EM>$id</EM> = <EM>$widget</EM>-><STRONG>repeat</STRONG>(<EM>ms</EM>?,<EM>callback</EM>?)</P>
- <P> <EM>$widget</EM>-><STRONG>afterCancel</STRONG>(<EM>$id</EM>)</P>
- <P> <EM>$id</EM> = <EM>$widget</EM>-><STRONG>afterIdle</STRONG>(<EM>callback</EM>)</P>
- <P> <EM>$widget</EM>-><STRONG>afterInfo</STRONG>?(<EM>$id</EM>)?</P>
- <P>
- <HR>
- <H1><A NAME="description">DESCRIPTION</A></H1>
- <P>This method is used to delay execution of the program or to execute
- a callback in background sometime in the future.</P>
- <P>In perl/Tk <EM>$widget</EM>-><STRONG>after</STRONG> is implemented via the class <CODE>Tk::After</CODE>,
- and callbacks are associated with <EM>$widget</EM>, and are automatically cancelled
- when the widget is destroyed. An almost identical interface, but without
- automatic cancel, and without repeat is provided via Tk::after method.</P>
- <P>The internal Tk::After class has the following synopsis:</P>
- <PRE>
- $id = Tk::After->new($widget,$time,'once',callback);
- $id = Tk::After->new($widget,$time,'repeat',callback);
- $id->cancel;</PRE>
- <P>The <STRONG>after</STRONG> method has several forms as follows:</P>
- <DL>
- <DT><STRONG><A NAME="item_after"><EM>$widget</EM>-><STRONG>after</STRONG>(<EM>ms</EM>)</A></STRONG><BR>
- <DD>
- The value <EM>ms</EM> must be an integer giving a time in milliseconds.
- The command sleeps for <EM>ms</EM> milliseconds and then returns.
- While the command is sleeping the application does not respond to
- events.
- <P></P>
- <DT><STRONG><EM>$widget</EM>-><STRONG>after</STRONG>(<EM>ms</EM>,<EM>callback</EM>)</STRONG><BR>
- <DD>
- In this form the command returns immediately, but it arranges
- for <EM>callback</EM> be executed <EM>ms</EM> milliseconds later as an
- event handler.
- The callback will be executed exactly once, at the given time.
- The command will be executed in context of <EM>$widget</EM>.
- If an error occurs while executing the delayed command then the
- <A HREF="../../../site/lib/Tk/Error.html">Tk::Error</A> mechanism is used to report the error.
- The <STRONG>after</STRONG> command returns an identifier (an object in the perl/Tk
- case) that can be used to cancel the delayed command using <STRONG>afterCancel</STRONG>.
- <P></P>
- <DT><STRONG><A NAME="item_repeat"><EM>$widget</EM>-><STRONG>repeat</STRONG>(<EM>ms</EM>,<EM>callback</EM>)</A></STRONG><BR>
- <DD>
- In this form the command returns immediately, but it arranges
- for <EM>callback</EM> be executed <EM>ms</EM> milliseconds later as an
- event handler. After <EM>callback</EM> has executed it is re-scheduled,
- to be executed in a futher <EM>ms</EM>, and so on until it is cancelled.
- <P></P>
- <DT><STRONG><A NAME="item_afterCancel"><EM>$widget</EM>-><STRONG>afterCancel</STRONG>(<EM>$id</EM>)</A></STRONG><BR>
- <DD>
- <DT><STRONG><A NAME="item_cancel"><EM>$id</EM>->cancel</A></STRONG><BR>
- <DD>
- Cancels the execution of a delayed command that
- was previously scheduled.
- <EM>$id</EM> indicates which command should be canceled; it must have
- been the return value from a previous <STRONG>after</STRONG> command.
- If the command given by <EM>$id</EM> has already been executed (and
- is not scheduled to be executed again) then <STRONG>afterCancel</STRONG>
- has no effect.
- <P></P>
- <DT><STRONG><EM>$widget</EM>-><STRONG>afterCancel</STRONG>(<EM>callback</EM>)</STRONG><BR>
- <DD>
- <EM>This form is not robust in perl/Tk - its use is deprecated.</EM>
- This command should also cancel the execution of a delayed command.
- The <EM>callback</EM> argument is compared with pending callbacks,
- if a match is found, that callback is
- cancelled and will never be executed; if no such callback is
- currently pending then the <STRONG>afterCancel</STRONG> has no effect.
- <P></P>
- <DT><STRONG><A NAME="item_afterIdle"><EM>$widget</EM>-><STRONG>afterIdle</STRONG>(<EM>callback</EM>)</A></STRONG><BR>
- <DD>
- Arranges for <EM>callback</EM> to be evaluated later as an idle callback.
- The script will be run exactly once, the next time the event
- loop is entered and there are no events to process.
- The command returns an identifier that can be used
- to cancel the delayed command using <STRONG>afterCancel</STRONG>.
- If an error occurs while executing the script then the
- <A HREF="../../../site/lib/Tk/Error.html">Tk::Error</A> mechanism is used to report the error.
- <P></P>
- <DT><STRONG><A NAME="item_afterInfo"><EM>$widget</EM>-><STRONG>afterInfo</STRONG>?(<EM>$id</EM>)?</A></STRONG><BR>
- <DD>
- This command returns information about existing event handlers. If no <EM>$id</EM>
- argument is supplied, the command returns a list of the identifiers for all
- existing event handlers created by the <STRONG>after</STRONG> command for this MainWindow. If
- <EM>$id</EM> is supplied, it specifies an existing handler; <EM>$id</EM> must have been the
- return value from some previous call to <STRONG>after</STRONG> and it must not have triggered
- yet or been cancelled. In this case the command returns a list with two elements.
- The first element of the list is the callback associated with <EM>$id</EM>, and the
- second element is either <STRONG>idle</STRONG> or <STRONG>timer</STRONG> to indicate what kind of event
- handler it is.
- <P></P></DL>
- <P>The <STRONG>after</STRONG>(<EM>ms</EM>) and <STRONG>afterIdle</STRONG> forms of the command
- assume that the application is event driven: the delayed commands
- will not be executed unless the application enters the event loop.
- In applications that are not normally event-driven,
- the event loop can be entered with the <STRONG>vwait</STRONG> and <STRONG>update</STRONG> commands.</P>
- <P>
- <HR>
- <H1><A NAME="see also">SEE ALSO</A></H1>
- <P><A HREF="../../../site/lib/Tk/Error.html">Tk::Error</A>
- <A HREF="../../../site/lib/Tk/callbacks.html">Tk::callbacks</A></P>
- <P>
- <HR>
- <H1><A NAME="keywords">KEYWORDS</A></H1>
- <P>cancel, delay, idle callback, sleep, time</P>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> Tk::after - Execute a command after a time delay</P></STRONG>
- </TD></TR>
- </TABLE>
-
- </BODY>
-
- </HTML>
-