<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( https://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) INRIA
 *
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
 *
 -->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
          xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML"
          xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
          xml:lang="en" xml:id="seteventhandler">
    <refnamediv>
        <refname>seteventhandler</refname>
        <refpurpose>set an event handler for
            the current graphic window
        </refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>seteventhandler(sfun_name)
            seteventhandler('')
        </synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>sfun_name</term>
                <listitem>
                    <para>a character string. The name of the Scilab function which is
                        intended to handle the events
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            The function allows the user to set a particular event handler for
            the current graphic window. <literal>seteventhandler('') </literal>
            removes the handler.
        </para>
        <para>
            For more information about event handler functions see the
            <link linkend="eventhandlerfunctions">event handler functions</link> help.
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
function my_eventhandler(win,x,y,ibut)
  if ibut==-1000 then return,end
  [x,y]=xchange(x,y,'i2f')
  gcf().info_message = msprintf('Event code %d at mouse position is (%f,%f)',ibut,x,y)
endfunction

plot2d()
seteventhandler('my_eventhandler')
//now:
//   -  move the mouse over the graphic window
//   -  press and release keys shifted or not with Ctrl pressed or not
//   -  press button, wait a little release
//   -  press and release button
//   -  double-click button

seteventhandler('') //suppress the event handler
 ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="addmenu">addmenu</link>
            </member>
            <member>
                <link linkend="xgetmouse">xgetmouse</link>
            </member>
            <member>
                <link linkend="xclick">xclick</link>
            </member>
            <member>
                <link linkend="xchange">xchange</link>
            </member>
            <member>
                <link linkend="eventhandlerfunctions">event handler functions</link>
            </member>
            <member>
                <link linkend="figure_properties">figure_properties</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
