<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) ENPC - Jean-Philippe Chancelier
 * Copyright (C) 2008 - INRIA - Vincent COUVERT
 *
 * 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:ns3="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"  xml:id="xclick" xml:lang="en">
    <refnamediv>
        <refname>xclick</refname>
        <refpurpose>Wait for a mouse click or an event in a graphic window.</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>[ibutton,xcoord,yxcoord,iwin,cbmenu]=xclick([flag])</synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>ibutton</term>
                <listitem>
                    <para>Real scalar (integer value): mouse button number, event code...
                        (See description below).
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>xcoord</term>
                <listitem>
                    <para>Real scalar: x-coordinate of the mouse pointer when
                        the click or event occurred, in current graphic scale (see <link linkend="gca">gca()</link>).
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>ycoord</term>
                <listitem>
                    <para>Real scalar: y-coordinate of the mouse pointer when
                        the click or event occurred, in current graphic scale (see <link linkend="gca">gca()</link>).
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>iwin</term>
                <listitem>
                    <para>Real scalar (integer value): number of the window where the
                        action occurred.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>cbmenu</term>
                <listitem>
                    <para>String: callback associated to a menu if
                        <literal>xclick</literal> returns due to a click on a menu. In this
                        case, <literal>ibutton</literal>, <literal>xcoord</literal>,
                        <literal>ycoord</literal>, and <literal>iwin</literal> take
                        arbitrary values.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>flag</term>
                <listitem>
                    <para>Real scalar (integer value): If present, the click event queue
                        is not cleared when entering xclick.
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            <literal>xclick</literal> waits for a mouse click, a keyboard event, a menu activation or windows closure in the graphics
            window. <literal>xclick</literal> prevents menu callback to be executed. Callback will be returned in <literal>cbmenu</literal>
            return value.
        </para>
        <para>If it is called with 3 left hand side arguments, it waits for a
            mouse click in the current graphics window.
        </para>
        <para>If it is called with 4 or 5 left hand side arguments, it waits for a
            mouse click in any graphics window.
        </para>
        <para>
            <warning>
                Warning, the returned coordinates <literal>xcoord</literal>,
                <literal>ycoord</literal> are relative to the current axes (see <link linkend="gca">gca()</link>).
            </warning>
        </para>
        <para>
            The values of <literal>ibutton</literal> are described below.
        </para>
        <variablelist>
            <varlistentry>
                <term>ibutton==0</term>
                <listitem>
                    <para>Left mouse button has been pressed.</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>ibutton==1</term>
                <listitem>
                    <para>Middle mouse button has been pressed.</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>ibutton==2</term>
                <listitem>
                    <para>Right mouse button has been pressed.</para>
                    <para/>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>ibutton==3</term>
                <listitem>
                    <para>Left mouse button has been clicked.</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>ibutton==4</term>
                <listitem>
                    <para>Middle mouse button has been clicked.</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>ibutton==5</term>
                <listitem>
                    <para>Right mouse button has been clicked.</para>
                    <para/>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>ibutton==10</term>
                <listitem>
                    <para>Left mouse button has been double-clicked.</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>ibutton==11</term>
                <listitem>
                    <para>Middle mouse button has been double-clicked.</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>ibutton==12</term>
                <listitem>
                    <para>Right mouse button has been double-clicked.</para>
                    <para/>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>ibutton &gt;=32</term>
                <listitem>
                    <para>
                        key with ASCII code <literal>ibutton</literal> has been
                        pressed.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>ibutton &lt;= -32</term>
                <listitem>
                    <para>
                        key with ASCII code <literal>-ibutton</literal> has been
                        released.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>ibutton &gt;=1000+32</term>
                <listitem>
                    <para>
                        key with ASCII code <literal>ibutton-1000</literal> has been
                        pressed while CTRL key pressed.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>ibutton==-1000</term>
                <listitem>
                    <para>graphic window has been closed.</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>ibutton==-2</term>
                <listitem>
                    <para>A dynamic menu has been selected and its callback is returned
                        in <literal>cbmenu</literal>.
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="gca">gca</link>
            </member>
            <member>
                <link linkend="locate">locate</link>
            </member>
            <member>
                <link linkend="xgetmouse">xgetmouse</link>
            </member>
            <member>
                <link linkend="seteventhandler">seteventhandler</link>
            </member>
        </simplelist>
    </refsection>
    <refsection role="history">
        <title>History</title>
        <revhistory>
            <revision>
                <revnumber>5.0</revnumber>
                <revdescription>
                    Closing a figure now returns the event code -1000 instead of -100.
                </revdescription>
            </revision>
        </revhistory>
    </refsection>
</refentry>
