<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link rel="stylesheet" href="style.css" type="text/css"> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> <link rel="Start" href="index.html"> <link rel="previous" href="Sdlkey.html"> <link rel="next" href="Sdlevent.html"> <link rel="Up" href="index.html"> <link title="Index of types" rel=Appendix href="index_types.html"> <link title="Index of exceptions" rel=Appendix href="index_exceptions.html"> <link title="Index of values" rel=Appendix href="index_values.html"> <link title="Index of modules" rel=Appendix href="index_modules.html"> <link title="Sdl" rel="Chapter" href="Sdl.html"> <link title="Sdlcdrom" rel="Chapter" href="Sdlcdrom.html"> <link title="Sdltimer" rel="Chapter" href="Sdltimer.html"> <link title="Sdljoystick" rel="Chapter" href="Sdljoystick.html"> <link title="Sdlkey" rel="Chapter" href="Sdlkey.html"> <link title="Sdlmouse" rel="Chapter" href="Sdlmouse.html"> <link title="Sdlevent" rel="Chapter" href="Sdlevent.html"> <link title="Sdlvideo" rel="Chapter" href="Sdlvideo.html"> <link title="Sdlwm" rel="Chapter" href="Sdlwm.html"> <link title="Sdlttf" rel="Chapter" href="Sdlttf.html"> <link title="Sdlloader" rel="Chapter" href="Sdlloader.html"> <link title="Sdlmixer" rel="Chapter" href="Sdlmixer.html"> <link title="Sdlgfx" rel="Chapter" href="Sdlgfx.html"><link title="Mouse state" rel="Section" href="#3_Mousestate"> <link title="Cursors " rel="Section" href="#3_Cursors"> <title>OCamlSDL 0.9.1 : Sdlmouse</title> </head> <body> <div class="navbar"><a href="Sdlkey.html">Previous</a> <a href="index.html">Up</a> <a href="Sdlevent.html">Next</a> </div> <center><h1>Module <a href="type_Sdlmouse.html">Sdlmouse</a></h1></center> <br> <pre><span class="keyword">module</span> Sdlmouse: <code class="code">sig</code> <a href="Sdlmouse.html">..</a> <code class="code">end</code></pre>Mouse event handling and cursors<br> <hr width="100%"> <br> <span id="3_Mousestate"><h3>Mouse state</h3></span><br> <br><code><span id="TYPEbutton"><span class="keyword">type</span> <code class="type"></code>button</span> = </code><table class="typetable"> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">BUTTON_LEFT</span></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">BUTTON_MIDDLE</span></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">BUTTON_RIGHT</span></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">BUTTON_WHEELUP</span></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">BUTTON_WHEELDOWN</span></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">BUTTON_X</span> <span class="keyword">of</span> <code class="type">int</code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >BUTTON_X is only seen in a Sdlevent.mousebutton_event, it is not returned by Sdlmouse.get_state</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr></table> <pre><span id="VALget_state"><span class="keyword">val</span> get_state</span> : <code class="type">?relative:bool -> unit -> int * int * <a href="Sdlmouse.html#TYPEbutton">button</a> list</code></pre><div class="info"> Retrieve the current state of the mouse : current mouse position and list of pressed buttons<br> </div> <div class="param_info"><code class="code">relative</code> : if true returns mouse delta instead of position</div> <pre><span id="VALwarp"><span class="keyword">val</span> warp</span> : <code class="type">int -> int -> unit</code></pre><div class="info"> Set the position of the mouse cursor (generates a mouse motion event)<br> </div> <br> <span id="3_Cursors"><h3>Cursors </h3></span><br> <pre><span id="TYPEcursor"><span class="keyword">type</span> <code class="type"></code>cursor</span> </pre> <div class="info"> abstract type for cursors<br> </div> <br><code><span id="TYPEcursor_data"><span class="keyword">type</span> <code class="type"></code>cursor_data</span> = {</code><table class="typetable"> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>data : <code class="type">(int, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array2.t</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >B/W cursor data</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>mask : <code class="type">(int, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array2.t</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >B/W cursor mask</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>w : <code class="type">int</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >width in pixels</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>h : <code class="type">int</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >height in pixels</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>hot_x : <code class="type">int</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >the "tip" of the cursor</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>hot_y : <code class="type">int</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >the "tip" of the cursor</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr></table> } <pre><span id="VALmake_cursor"><span class="keyword">val</span> make_cursor</span> : <code class="type">data:(int, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array2.t -><br> mask:(int, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array2.t -><br> hot_x:int -> hot_y:int -> <a href="Sdlmouse.html#TYPEcursor">cursor</a></code></pre><div class="info"> Create a cursor using the specified data and mask (in MSB format). <p> The cursor is created in black and white according to the following: <pre>data mask resulting pixel on screen 0 1 White 1 1 Black 0 0 Transparent 1 0 Inverted color if possible, black if not.</pre> <p> Cursors created with this function must be freed with <a href="Sdlmouse.html#VALfree_cursor"><code class="code">Sdlmouse.free_cursor</code></a>.<br> </div> <pre><span id="VALfree_cursor"><span class="keyword">val</span> free_cursor</span> : <code class="type"><a href="Sdlmouse.html#TYPEcursor">cursor</a> -> unit</code></pre><div class="info"> Deallocates a cursor.<br> </div> <pre><span id="VALset_cursor"><span class="keyword">val</span> set_cursor</span> : <code class="type"><a href="Sdlmouse.html#TYPEcursor">cursor</a> -> unit</code></pre><div class="info"> Set the currently active cursor to the specified one. If the cursor is currently visible, the change will be immediately represented on the display.<br> </div> <pre><span id="VALget_cursor"><span class="keyword">val</span> get_cursor</span> : <code class="type">unit -> <a href="Sdlmouse.html#TYPEcursor">cursor</a></code></pre><div class="info"> Returns the currently active cursor.<br> </div> <pre><span id="VALcursor_visible"><span class="keyword">val</span> cursor_visible</span> : <code class="type">unit -> bool</code></pre><div class="info"> Tests if cursor is shown on screen<br> </div> <pre><span id="VALshow_cursor"><span class="keyword">val</span> show_cursor</span> : <code class="type">bool -> unit</code></pre><div class="info"> Toggle cursor display<br> </div> <pre><span id="VALcursor_data"><span class="keyword">val</span> cursor_data</span> : <code class="type"><a href="Sdlmouse.html#TYPEcursor">cursor</a> -> <a href="Sdlmouse.html#TYPEcursor_data">cursor_data</a></code></pre><div class="info"> converts an abstract cursor value to concrete cursor data<br> </div> <pre><span id="VALpprint_cursor"><span class="keyword">val</span> pprint_cursor</span> : <code class="type"><a href="Sdlmouse.html#TYPEcursor">cursor</a> -> unit</code></pre><div class="info"> for debugging : prints on stdout<br> </div> <pre><span id="VALconvert_to_cursor"><span class="keyword">val</span> convert_to_cursor</span> : <code class="type">data:int array -><br> mask:int array -> w:int -> h:int -> hot_x:int -> hot_y:int -> <a href="Sdlmouse.html#TYPEcursor">cursor</a></code></pre></body></html>