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