Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 3e60ff9d4d6f58c8fbd17208f14089fa > files > 79

octave-doc-3.2.3-3mdv2010.0.i586.rpm

<html lang="en">
<head>
<title>Callbacks - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Advanced-Plotting.html#Advanced-Plotting" title="Advanced Plotting">
<link rel="prev" href="Marker-Styles.html#Marker-Styles" title="Marker Styles">
<link rel="next" href="Object-Groups.html#Object-Groups" title="Object Groups">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="Callbacks"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Object-Groups.html#Object-Groups">Object Groups</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Marker-Styles.html#Marker-Styles">Marker Styles</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Advanced-Plotting.html#Advanced-Plotting">Advanced Plotting</a>
<hr>
</div>

<h4 class="subsection">15.2.7 Callbacks</h4>

<p><a name="index-callbacks-1216"></a>
Callback functions can be associated with graphics objects and triggered
after certain events occur.  The basic structure of all callback function
is

<pre class="example">     function mycallback (src, data)
     ...
     endfunction
</pre>
   <p>where <code>src</code> gives a handle to the source of the callback, and
<code>code</code> gives some event specific data.  This can then be associated
with an object either at the objects creation or later with the
<code>set</code> function.  For example

<pre class="example">     plot (x, "DeleteFcn", @(s, e) disp("Window Deleted"))
</pre>
   <p class="noindent">where at the moment that the plot is deleted, the message "Window
Deleted" will be displayed.

   <p>Additional user arguments can be passed to callback functions, and will
be passed after the 2 default arguments.  For example

<pre class="example">     plot (x, "DeleteFcn", {@mycallback, "1"})
     ...
     function mycallback (src, data, a1)
       fprintf ("Closing plot %d\n", a1);
     endfunction
</pre>
   <p>The basic callback functions that are available for all graphics objects
are

     <ul>
<li>CreateFcn
This is the callback that is called at the moment of the objects
creation.  It is not called if the object is altered in any way, and so
it only makes sense to define this callback in the function call that
defines the object.  Callbacks that are added to <code>CreateFcn</code> later with
the <code>set</code> function will never be executed.

     <li>DeleteFcn
This is the callback that is called at the moment an object is deleted.

     <li>ButtonDownFcn
This is the callback that is called if a mouse button is pressed while
the pointer is over this object.  Note, that the gnuplot interface does
not respect this callback. 
</ul>

   <p>The object and figure that the event occurred in that resulted in the
callback being called can be found with the <code>gcbo</code> and <code>gcbf</code>
functions.

<!-- ./plot/gcbo.m -->
   <p><a name="doc_002dgcbo"></a>

<div class="defun">
&mdash; Function File: <var>h</var> = <b>gcbo</b> ()<var><a name="index-gcbo-1217"></a></var><br>
&mdash; Function File: [<var>h</var>, <var>fig</var>] = <b>gcbo</b> ()<var><a name="index-gcbo-1218"></a></var><br>
<blockquote><p>Return a handle to the object whose callback is currently
executing.  If no callback is executing, this function returns the
empty matrix.  This handle is obtained from the root object property
"CallbackObject".

        <p>Additionally return the handle of the figure containing the
object whose callback is currently executing.  If no callback is
executing, the second output is also set to the empty matrix.

     <!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
     <!-- A simple blank line produces the correct behavior. -->
     <!-- @sp 1 -->
     <p class="noindent"><strong>See also:</strong> <a href="doc_002dgcf.html#doc_002dgcf">gcf</a>, <a href="doc_002dgca.html#doc_002dgca">gca</a>, <a href="doc_002dgcbf.html#doc_002dgcbf">gcbf</a>. 
</p></blockquote></div>

<!-- ./plot/gcbf.m -->
   <p><a name="doc_002dgcbf"></a>

<div class="defun">
&mdash; Function File: <var>fig</var> = <b>gcbf</b> ()<var><a name="index-gcbf-1219"></a></var><br>
<blockquote><p>Return a handle to the figure containing the object whose callback
is currently executing.  If no callback is executing, this function
returns the empty matrix.  The handle returned by this function is
the same as the second output argument of gcbo.

     <!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
     <!-- A simple blank line produces the correct behavior. -->
     <!-- @sp 1 -->
     <p class="noindent"><strong>See also:</strong> <a href="doc_002dgcf.html#doc_002dgcf">gcf</a>, <a href="doc_002dgca.html#doc_002dgca">gca</a>, <a href="doc_002dgcbo.html#doc_002dgcbo">gcbo</a>. 
</p></blockquote></div>

   <p>Callbacks can equally be added to properties with the <code>addlistener</code>
function described below.

   </body></html>