Merge branch 'master' of git.shadowcat.co.uk:SDL-Site
[sdlgit/SDL-Site.git] / pages / SDL-Mouse.html-inc
CommitLineData
b82df135 1<div class="pod">
2<!-- INDEX START -->
3<h3 id="TOP">Index</h3>
4
5<ul><li><a href="#NAME">NAME</a></li>
bb5f3b83 6<li><a href="#CATEGORY">CATEGORY</a></li>
801213bd 7<li><a href="#CONSTANTS">CONSTANTS</a></li>
bb5f3b83 8<li><a href="#METHODS">METHODS</a>
9<ul><li><a href="#warp_mouse">warp_mouse</a></li>
bb5f3b83 10<li><a href="#set_cursor">set_cursor</a></li>
11<li><a href="#get_cursor">get_cursor</a></li>
801213bd 12<li><a href="#show_cursor">show_cursor</a></li>
bb5f3b83 13</ul>
b82df135 14</li>
c7e8d3c6 15<li><a href="#SEE_ALSO">SEE ALSO</a></li>
16<li><a href="#AUTHORS">AUTHORS</a>
801213bd 17</li>
b82df135 18</ul><hr />
3774ca11 19<!-- INDEX END --><a href="assets/Mouse.png" target="_blank"><img src="assets/Mouse.png" style="height: 160px" alt="Mouse.png"/></a><hr />
b82df135 20
21<h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
22<div id="NAME_CONTENT">
801213bd 23<p>SDL::Mouse - SDL Bindings for the Mouse device</p>
b82df135 24
25</div>
26<h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
27<div id="CATEGORY_CONTENT">
bb5f3b83 28<p>Core, Mouse</p>
29
30</div>
801213bd 31<h1 id="CONSTANTS">CONSTANTS</h1><p><a href="#TOP" class="toplink">Top</a></p>
32<div id="CONSTANTS_CONTENT">
33<p>The constants for SDL::Mouse belong to SDL::Events/SDL::Event, under the export tag of <code>':state'</code>.</p>
34
35</div>
bb5f3b83 36<h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
37<div id="METHODS_CONTENT">
38
39</div>
40<h2 id="warp_mouse">warp_mouse</h2>
41<div id="warp_mouse_CONTENT">
801213bd 42<pre> SDL::Mouse::warp_mouse( $x, $y );
bb5f3b83 43
44</pre>
801213bd 45<p>Set the position of the mouse cursor (generates a mouse motion event).
46Even if the mouse is warped to where it currently is, a mouse motion event is generated.</p>
bb5f3b83 47
48</div>
bb5f3b83 49<h2 id="set_cursor">set_cursor</h2>
50<div id="set_cursor_CONTENT">
801213bd 51<pre> SDL::Mouse::set_cursor( $cursor_object );
bb5f3b83 52
53</pre>
801213bd 54<p>Sets the currently active cursor to the specified one.
55See <a href="SDL-Cursor.html">SDL::Cursor</a> for details on cursor objects.
56If the cursor is currently visible, the change will be immediately represented on the display.
57<code>set_cursor()</code> can be used to force cursor redraw, if this is desired for any reason.</p>
bb5f3b83 58
59</div>
60<h2 id="get_cursor">get_cursor</h2>
61<div id="get_cursor_CONTENT">
801213bd 62<pre> my $cursor_object = SDL::Mouse::get_cursor;
bb5f3b83 63
64</pre>
65<p>Gets the currently active mouse cursor.</p>
66
67</div>
68<h2 id="show_cursor">show_cursor</h2>
69<div id="show_cursor_CONTENT">
801213bd 70<pre> my $return = SDL::Mouse::show_cursor( $state );
bb5f3b83 71
72</pre>
801213bd 73<p>Toggle whether or not the cursor is shown on the screen.
74Passing <code>SDL_ENABLE</code> displays the cursor and passing <code>SDL_DISABLE</code> hides it.
bb5f3b83 75The current state of the mouse cursor can be queried by passing <code>SDL_QUERY</code>, either <code>SDL_DISABLE</code> or <code>SDL_ENABLE</code> will be returned.</p>
76<pre> use SDL;
77 use SDL::Mouse;
78 use SDL::Video;
801213bd 79 use SDL::Events ':state'; #For the constants
bb5f3b83 80
81 SDL::init(SDL_INIT_VIDEO);
801213bd 82 SDL::Video::set_video_mode(640, 480, 16, SDL_SWSURFACE);
bb5f3b83 83
84 printf(&quot;Cursor is %s\n&quot;, SDL::Mouse::show_cursor(SDL_QUERY) ? 'visible' : 'not visible');
85
86 sleep(3);
87
88 SDL::Mouse::show_cursor(SDL_DISABLE);
89 printf(&quot;Cursor is %s\n&quot;, SDL::Mouse::show_cursor(SDL_QUERY) ? 'visible' : 'not visible');
90
91 sleep(3);
92
93 SDL::Mouse::show_cursor(SDL_ENABLE);
94 printf(&quot;Cursor is %s\n&quot;, SDL::Mouse::show_cursor(SDL_QUERY) ? 'visible' : 'not visible');
95
96 sleep(3);
97
98</pre>
b82df135 99
100</div>
801213bd 101<h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p>
102<div id="SEE_ALSO_CONTENT">
103<p><a href="SDL-Cursor.html">SDL::Cursor</a></p>
104
105</div>
c7e8d3c6 106<h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p>
107<div id="AUTHORS_CONTENT">
1dbe1697 108<p>See <a href="/SDL.html#AUTHORS">/SDL.html#AUTHORS</a>.</p>
c7e8d3c6 109
110</div>
b82df135 111</div>