sfmlinstaller

sfmlinstaller Mercurial Source Tree


Root/windows/doc/html/classsf_1_1Mouse.htm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head>
        <title>SFML - Simple and Fast Multimedia Library</title>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
        <!--<link rel='stylesheet' type='text/css' href="http://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic"/>-->
        <link rel="stylesheet" type="text/css" href="doxygen.css" title="default" media="screen,print" />
    </head>
    <body>
        <div id="banner-container">
            <div id="banner">
                <span id="sfml">SFML</span>
            </div>
        </div>
        <div id="content">
<!-- Generated by Doxygen 1.8.2 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.htm"><span>Main Page</span></a></li>
      <li><a href="modules.htm"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.htm"><span>Classes</span></a></li>
      <li><a href="files.htm"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.htm"><span>Class List</span></a></li>
      <li><a href="classes.htm"><span>Class Index</span></a></li>
      <li><a href="hierarchy.htm"><span>Class Hierarchy</span></a></li>
      <li><a href="functions.htm"><span>Class Members</span></a></li>
    </ul>
  </div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><b>sf</b></li><li class="navelem"><a class="el" href="classsf_1_1Mouse.htm">Mouse</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-types">Public Types</a> |
<a href="#pub-static-methods">Static Public Member Functions</a> |
<a href="classsf_1_1Mouse-members.htm">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">sf::Mouse Class Reference<div class="ingroups"><a class="el" href="group__window.htm">Window module</a></div></div>  </div>
</div><!--header-->
<div class="contents">
 
<p>Give access to the real-time state of the mouse. 
 <a href="classsf_1_1Mouse.htm#details">More...</a></p>
 
<p><code>#include <<a class="el" href="Mouse_8hpp_source.htm">Mouse.hpp</a>></code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr class="memitem:a4fb128be433f9aafe66bc0c605daaa90"><td class="memItemLeft" align="right" valign="top">enum  </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1Mouse.htm#a4fb128be433f9aafe66bc0c605daaa90">Button</a> { <br/>
  <a class="el" href="classsf_1_1Mouse.htm#a4fb128be433f9aafe66bc0c605daaa90a8bb4856e1ec7f6b6a8605effdfc0eee8">Left</a>,
<br/>
  <a class="el" href="classsf_1_1Mouse.htm#a4fb128be433f9aafe66bc0c605daaa90af2cff24ab6c26daf079b11189f982fc4">Right</a>,
<br/>
  <a class="el" href="classsf_1_1Mouse.htm#a4fb128be433f9aafe66bc0c605daaa90a2c353189c4b11cf216d7caddafcc609d">Middle</a>,
<br/>
  <a class="el" href="classsf_1_1Mouse.htm#a4fb128be433f9aafe66bc0c605daaa90aecc7f3ce9ad6a60b9b0027876446b8d7">XButton1</a>,
<br/>
  <a class="el" href="classsf_1_1Mouse.htm#a4fb128be433f9aafe66bc0c605daaa90a03fa056fd0dd9d629c205d91a8ef1b5a">XButton2</a>,
<br/>
  <a class="el" href="classsf_1_1Mouse.htm#a4fb128be433f9aafe66bc0c605daaa90a52a1d434289774240ddaa22496762402">ButtonCount</a>
<br/>
 }</td></tr>
<tr class="memdesc:a4fb128be433f9aafe66bc0c605daaa90"><td class="mdescLeft"> </td><td class="mdescRight"><a class="el" href="classsf_1_1Mouse.htm" title="Give access to the real-time state of the mouse.">Mouse</a> buttons.  <a href="classsf_1_1Mouse.htm#a4fb128be433f9aafe66bc0c605daaa90">More...</a><br/></td></tr>
<tr class="separator:a4fb128be433f9aafe66bc0c605daaa90"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr class="memitem:ab647159eb88e369a0332a9c5a7ba6687"><td class="memItemLeft" align="right" valign="top">static bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1Mouse.htm#ab647159eb88e369a0332a9c5a7ba6687">isButtonPressed</a> (<a class="el" href="classsf_1_1Mouse.htm#a4fb128be433f9aafe66bc0c605daaa90">Button</a> button)</td></tr>
<tr class="memdesc:ab647159eb88e369a0332a9c5a7ba6687"><td class="mdescLeft"> </td><td class="mdescRight">Check if a mouse button is pressed.  <a href="#ab647159eb88e369a0332a9c5a7ba6687"></a><br/></td></tr>
<tr class="separator:ab647159eb88e369a0332a9c5a7ba6687"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ac368680f797b7f6e4f50b5b7928c1387"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="classsf_1_1Vector2.htm">Vector2i</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1Mouse.htm#ac368680f797b7f6e4f50b5b7928c1387">getPosition</a> ()</td></tr>
<tr class="memdesc:ac368680f797b7f6e4f50b5b7928c1387"><td class="mdescLeft"> </td><td class="mdescRight">Get the current position of the mouse in desktop coordinates.  <a href="#ac368680f797b7f6e4f50b5b7928c1387"></a><br/></td></tr>
<tr class="separator:ac368680f797b7f6e4f50b5b7928c1387"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a93b4d2ebef728e77a0ec9d83c1e0b0c8"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="classsf_1_1Vector2.htm">Vector2i</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1Mouse.htm#a93b4d2ebef728e77a0ec9d83c1e0b0c8">getPosition</a> (const <a class="el" href="classsf_1_1Window.htm">Window</a> &relativeTo)</td></tr>
<tr class="memdesc:a93b4d2ebef728e77a0ec9d83c1e0b0c8"><td class="mdescLeft"> </td><td class="mdescRight">Get the current position of the mouse in window coordinates.  <a href="#a93b4d2ebef728e77a0ec9d83c1e0b0c8"></a><br/></td></tr>
<tr class="separator:a93b4d2ebef728e77a0ec9d83c1e0b0c8"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a1222e16c583be9e3d176d86e0b7817d7"><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1Mouse.htm#a1222e16c583be9e3d176d86e0b7817d7">setPosition</a> (const <a class="el" href="classsf_1_1Vector2.htm">Vector2i</a> &position)</td></tr>
<tr class="memdesc:a1222e16c583be9e3d176d86e0b7817d7"><td class="mdescLeft"> </td><td class="mdescRight">Set the current position of the mouse in desktop coordinates.  <a href="#a1222e16c583be9e3d176d86e0b7817d7"></a><br/></td></tr>
<tr class="separator:a1222e16c583be9e3d176d86e0b7817d7"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ad9b16ec7041531315f06b26b413dfea8"><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1Mouse.htm#ad9b16ec7041531315f06b26b413dfea8">setPosition</a> (const <a class="el" href="classsf_1_1Vector2.htm">Vector2i</a> &position, const <a class="el" href="classsf_1_1Window.htm">Window</a> &relativeTo)</td></tr>
<tr class="memdesc:ad9b16ec7041531315f06b26b413dfea8"><td class="mdescLeft"> </td><td class="mdescRight">Set the current position of the mouse in window coordinates.  <a href="#ad9b16ec7041531315f06b26b413dfea8"></a><br/></td></tr>
<tr class="separator:ad9b16ec7041531315f06b26b413dfea8"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Give access to the real-time state of the mouse. </p>
<p><a class="el" href="classsf_1_1Mouse.htm" title="Give access to the real-time state of the mouse.">sf::Mouse</a> provides an interface to the state of the mouse.</p>
<p>It only contains static functions (a single mouse is assumed), so it's not meant to be instanciated.</p>
<p>This class allows users to query the mouse state at any time and directly, without having to deal with a window and its events. Compared to the MouseMoved, MouseButtonPressed and MouseButtonReleased events, <a class="el" href="classsf_1_1Mouse.htm" title="Give access to the real-time state of the mouse.">sf::Mouse</a> can retrieve the state of the cursor and the buttons at any time (you don't need to store and update a boolean on your side in order to know if a button is pressed or released), and you always get the real state of the mouse, even if it is moved, pressed or released when your window is out of focus and no event is triggered.</p>
<p>The setPosition and getPosition functions can be used to change or retrieve the current position of the mouse pointer. There are two versions: one that operates in global coordinates (relative to the desktop) and one that operates in window coordinates (relative to a specific window).</p>
<p>Usage example: </p>
<div class="fragment"><div class="line"><span class="keywordflow">if</span> (<a class="code" href="classsf_1_1Mouse.htm#ab647159eb88e369a0332a9c5a7ba6687" title="Check if a mouse button is pressed.">sf::Mouse::isButtonPressed</a>(<a class="code" href="classsf_1_1Mouse.htm#a4fb128be433f9aafe66bc0c605daaa90a8bb4856e1ec7f6b6a8605effdfc0eee8" title="The left mouse button.">sf::Mouse::Left</a>))</div>
<div class="line">{</div>
<div class="line">    <span class="comment">// left click...</span></div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="comment">// get global mouse position</span></div>
<div class="line"><a class="code" href="classsf_1_1Vector2.htm" title="Utility template class for manipulating 2-dimensional vectors.">sf::Vector2i</a> position = <a class="code" href="classsf_1_1Mouse.htm#ac368680f797b7f6e4f50b5b7928c1387" title="Get the current position of the mouse in desktop coordinates.">sf::Mouse::getPosition</a>();</div>
<div class="line"></div>
<div class="line"><span class="comment">// set mouse position relative to a window</span></div>
<div class="line"><a class="code" href="classsf_1_1Mouse.htm#a1222e16c583be9e3d176d86e0b7817d7" title="Set the current position of the mouse in desktop coordinates.">sf::Mouse::setPosition</a>(<a class="code" href="classsf_1_1Vector2.htm" title="Utility template class for manipulating 2-dimensional vectors.">sf::Vector2i</a>(100, 200), window);</div>
</div><!-- fragment --><dl class="section see"><dt>See Also</dt><dd><a class="el" href="classsf_1_1Joystick.htm" title="Give access to the real-time state of the joysticks.">sf::Joystick</a>, <a class="el" href="classsf_1_1Keyboard.htm" title="Give access to the real-time state of the keyboard.">sf::Keyboard</a> </dd></dl>
 
<p>Definition at line <a class="el" href="Mouse_8hpp_source.htm#l00043">43</a> of file <a class="el" href="Mouse_8hpp_source.htm">Mouse.hpp</a>.</p>
</div><h2 class="groupheader">Member Enumeration Documentation</h2>
<a class="anchor" id="a4fb128be433f9aafe66bc0c605daaa90"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="classsf_1_1Mouse.htm#a4fb128be433f9aafe66bc0c605daaa90">sf::Mouse::Button</a></td>
        </tr>
      </table>
</div><div class="memdoc">
 
<p><a class="el" href="classsf_1_1Mouse.htm" title="Give access to the real-time state of the mouse.">Mouse</a> buttons. </p>
<dl><dt><b>Enumerator: </b></dt><dd><table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><em><a class="anchor" id="a4fb128be433f9aafe66bc0c605daaa90a8bb4856e1ec7f6b6a8605effdfc0eee8"></a>Left</em> </td><td>
<p>The left mouse button. </p>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="a4fb128be433f9aafe66bc0c605daaa90af2cff24ab6c26daf079b11189f982fc4"></a>Right</em> </td><td>
<p>The right mouse button. </p>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="a4fb128be433f9aafe66bc0c605daaa90a2c353189c4b11cf216d7caddafcc609d"></a>Middle</em> </td><td>
<p>The middle (wheel) mouse button. </p>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="a4fb128be433f9aafe66bc0c605daaa90aecc7f3ce9ad6a60b9b0027876446b8d7"></a>XButton1</em> </td><td>
<p>The first extra mouse button. </p>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="a4fb128be433f9aafe66bc0c605daaa90a03fa056fd0dd9d629c205d91a8ef1b5a"></a>XButton2</em> </td><td>
<p>The second extra mouse button. </p>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="a4fb128be433f9aafe66bc0c605daaa90a52a1d434289774240ddaa22496762402"></a>ButtonCount</em> </td><td>
<p>Keep last – the total number of mouse buttons. </p>
</td></tr>
</table>
</dd>
</dl>
 
<p>Definition at line <a class="el" href="Mouse_8hpp_source.htm#l00051">51</a> of file <a class="el" href="Mouse_8hpp_source.htm">Mouse.hpp</a>.</p>
 
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="ac368680f797b7f6e4f50b5b7928c1387"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static <a class="el" href="classsf_1_1Vector2.htm">Vector2i</a> sf::Mouse::getPosition </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
 
<p>Get the current position of the mouse in desktop coordinates. </p>
<p>This function returns the global position of the mouse cursor on the desktop.</p>
<dl class="section return"><dt>Returns</dt><dd>Current position of the mouse </dd></dl>
 
</div>
</div>
<a class="anchor" id="a93b4d2ebef728e77a0ec9d83c1e0b0c8"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static <a class="el" href="classsf_1_1Vector2.htm">Vector2i</a> sf::Mouse::getPosition </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classsf_1_1Window.htm">Window</a> & </td>
          <td class="paramname"><em>relativeTo</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
 
<p>Get the current position of the mouse in window coordinates. </p>
<p>This function returns the current position of the mouse cursor, relative to the given window.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">relativeTo</td><td>Reference window</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Current position of the mouse </dd></dl>
 
</div>
</div>
<a class="anchor" id="ab647159eb88e369a0332a9c5a7ba6687"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static bool sf::Mouse::isButtonPressed </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classsf_1_1Mouse.htm#a4fb128be433f9aafe66bc0c605daaa90">Button</a> </td>
          <td class="paramname"><em>button</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
 
<p>Check if a mouse button is pressed. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">button</td><td>Button to check</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>True if the button is pressed, false otherwise </dd></dl>
 
</div>
</div>
<a class="anchor" id="a1222e16c583be9e3d176d86e0b7817d7"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void sf::Mouse::setPosition </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classsf_1_1Vector2.htm">Vector2i</a> & </td>
          <td class="paramname"><em>position</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
 
<p>Set the current position of the mouse in desktop coordinates. </p>
<p>This function sets the global position of the mouse cursor on the desktop.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">position</td><td>New position of the mouse </td></tr>
  </table>
  </dd>
</dl>
 
</div>
</div>
<a class="anchor" id="ad9b16ec7041531315f06b26b413dfea8"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void sf::Mouse::setPosition </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classsf_1_1Vector2.htm">Vector2i</a> & </td>
          <td class="paramname"><em>position</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classsf_1_1Window.htm">Window</a> & </td>
          <td class="paramname"><em>relativeTo</em> </td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
 
<p>Set the current position of the mouse in window coordinates. </p>
<p>This function sets the current position of the mouse cursor, relative to the given window.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">position</td><td>New position of the mouse </td></tr>
    <tr><td class="paramname">relativeTo</td><td>Reference window </td></tr>
  </table>
  </dd>
</dl>
 
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="Mouse_8hpp_source.htm">Mouse.hpp</a></li>
</ul>
</div><!-- contents -->
        </div>
        <div id="footer-container">
            <div id="footer">
                Copyright � Laurent Gomila  :: 
                Documentation generated by <a href="http://www.doxygen.org/" title="doxygen website">doxygen</a>  :: 
            </div>
        </div>
    <script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
 
  ga('create', 'UA-41898676-1', 'srchub.org');
  ga('send', 'pageview');
Page rendered in 1.18328s using 11 queries.
Source at commit tip created 11 years 11 months ago.
By Nathan Adams, Initial commit

Archive Download this file

Branches

Tags

Page rendered in 1.18328s using 11 queries.