Source

pygame / docs / ref / mouse.html

Full commit

<html>
<title>mouse - Pygame Documentation</title>
<body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>


<table cellspacing=3 width=100%><tr><td bgcolor=#00000>
<table width=100%><tr><td bgcolor=c2fc20 align=center>
    <a href=http://www.pygame.org>
    <img src=../pygame_tiny.gif border=0 width=200 height=60></a><br>
    <b>pygame&nbsp;&nbsp;&nbsp;documentation</b>
</td><td bgcolor=6aee28 align=center valign=top width=100%>

	||&nbsp;
	<a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
	<a href=../index.html>Help Contents</a> &nbsp;||
	<a href=index.html>Reference Index</a> &nbsp;||
	<br>&nbsp;<br>
	
<a href=cdrom.html>Cdrom</a>&nbsp;||&nbsp;
<a href=cursors.html>Cursors</a>&nbsp;||&nbsp;
<a href=display.html>Display</a>&nbsp;||&nbsp;
<a href=draw.html>Draw</a>&nbsp;||&nbsp;
<a href=event.html>Event</a>&nbsp;||&nbsp;
<a href=font.html>Font</a>&nbsp;||&nbsp;
<a href=image.html>Image</a>&nbsp;||&nbsp;
<a href=joystick.html>Joystick</a>&nbsp;||&nbsp;
<a href=key.html>Key</a>&nbsp;||&nbsp;
<a href=mixer.html>Mixer</a>&nbsp;||&nbsp;
<a href=mouse.html>Mouse</a>&nbsp;||&nbsp;
<a href=movie.html>Movie</a>&nbsp;||&nbsp;
<a href=music.html>Music</a>&nbsp;||&nbsp;
<a href=overlay.html>Overlay</a>&nbsp;||&nbsp;
<a href=pygame.html>Pygame</a>&nbsp;||&nbsp;
<a href=rect.html>Rect</a>&nbsp;||&nbsp;
<a href=sndarray.html>Sndarray</a>&nbsp;||&nbsp;
<a href=sprite.html>Sprite</a>&nbsp;||&nbsp;
<a href=surface.html>Surface</a>&nbsp;||&nbsp;
<a href=surfarray.html>Surfarray</a>&nbsp;||&nbsp;
<a href=time.html>Time</a>&nbsp;||&nbsp;
<a href=transform.html>Transform</a>
</p>


</td></tr></table></td></tr></table>
<br>


<a name="pygame.mouse">
<big><b>pygame.mouse</big></b><br><ul>
  <i>pygame module to work with the mouse</i><br>
<ul><small><table>
  <tr><td><a href="mouse.html#pygame.mouse.get_pressed">pygame.mouse.get_pressed</a></td><td>get the state of the mouse buttons</td></tr>
  <tr><td><a href="mouse.html#pygame.mouse.get_pos">pygame.mouse.get_pos</a></td><td>get the mouse cursor position</td></tr>
  <tr><td><a href="mouse.html#pygame.mouse.get_rel">pygame.mouse.get_rel</a></td><td>get the amount of mouse movement</td></tr>
  <tr><td><a href="mouse.html#pygame.mouse.set_pos">pygame.mouse.set_pos</a></td><td>set the mouse cursor position</td></tr>
  <tr><td><a href="mouse.html#pygame.mouse.set_visible">pygame.mouse.set_visible</a></td><td>hide or show the mouse cursor</td></tr>
  <tr><td><a href="mouse.html#pygame.mouse.get_focused">pygame.mouse.get_focused</a></td><td>check if the display is receiving mouse input</td></tr>
  <tr><td><a href="mouse.html#pygame.mouse.set_cursor">pygame.mouse.set_cursor</a></td><td>set the image for the system mouse cursor</td></tr>
  <tr><td><a href="mouse.html#pygame.mouse.get_cursor">pygame.mouse.get_cursor</a></td><td>get the image for the system mouse cursor</td></tr>
</table></small></ul>
<p>The mouse functions can be used to get the current state of the mouse device. These functions can also alter the system cursor for the mouse. </p>
<p>When the display mode is set, the event queue will start receiving mouse events. The mouse buttons generate <tt>pygame.MOUSEBUTTONDOWN</tt> and <tt>pygame.MOUSEBUTTONUP</tt> events when they are pressed and released. These events contain a button attribute representing which button was pressed. The mouse wheel will generate <tt>pygame.MOUSEBUTTONDOWN</tt> events when rolled. The button will be set to 4 when the wheel is rolled up, and to button 5 when the wheel is rolled down. Anytime the mouse is moved it generates a <tt>pygame.MOUSEMOTION</tt> event. The mouse movement is broken into small and accurate motion events. As the mouse is moving many motion events will be placed on the queue. Mouse motion events that are not properly cleaned from the event queue are the primary reason the event queue fills up. </p>
<p>If the mouse cursor is hidden, and input is grabbed to the current display the mouse will enter a virtual input mode, where the relative movements of the mouse will never be stopped by the borders of the screen. See the functions <tt><a href="mouse.html#pygame.mouse.set_visible">pygame.mouse.set_visible</a></tt> and <tt><a href="event.html#pygame.event.set_grab">pygame.event.set_grab</a></tt> to get this configured. </p>
 &nbsp;<br> 


<a name="pygame.mouse.get_pressed">
<big><b>pygame.mouse.get_pressed</big></b><br><ul>
  <i>get the state of the mouse buttons</i><br>
  <tt>pygame.moouse.get_pressed(): return (button1, button2, button3)</tt><br>
<p>Returns a sequence of booleans representing the state of all the mouse buttons. <tt>A</tt> true value means the mouse is currently being pressed at the time of the call. </p>
 &nbsp;<br> 
<br></ul>


<a name="pygame.mouse.get_pos">
<big><b>pygame.mouse.get_pos</big></b><br><ul>
  <i>get the mouse cursor position</i><br>
  <tt>pygame.mouse.get_pos(): return (x, y)</tt><br>
<p>Returns the <tt>X</tt> and <tt>Y</tt> position of the mouse cursor. The position is relative the the top-left corner of the display. The cursor position can be located outside of the display window, but is always constrained to the screen. </p>
 &nbsp;<br> 
<br></ul>


<a name="pygame.mouse.get_rel">
<big><b>pygame.mouse.get_rel</big></b><br><ul>
  <i>get the amount of mouse movement</i><br>
  <tt>pygame.mouse.get_rel(): return (x, y)</tt><br>
<p>Returns the amount of movement in <tt>X</tt> and <tt>Y</tt> since the previous call to this function. The relative movement of the mouse cursor is constrained to the edges of the screen, but see the virtual input mouse mode for a way around this. </p>
 &nbsp;<br> 
<br></ul>


<a name="pygame.mouse.set_pos">
<big><b>pygame.mouse.set_pos</big></b><br><ul>
  <i>set the mouse cursor position</i><br>
  <tt>pygame.mouse.set_pos([x, y]): return None</tt><br>
<p>Set the current mouse position to arguments given. If the mouse cursor is visible it will jump to the new coordinates. Moving the mouse will generate a new <tt>pygaqme.MOUSEMOTION</tt> event. </p>
 &nbsp;<br> 
<br></ul>


<a name="pygame.mouse.set_visible">
<big><b>pygame.mouse.set_visible</big></b><br><ul>
  <i>hide or show the mouse cursor</i><br>
  <tt>pygame.mouse.set_visible(bool): return bool</tt><br>
<p>If the bool argument is true, the mouse cursor will be visible. This will return the previous visible state of the cursor. </p>
 &nbsp;<br> 
<br></ul>


<a name="pygame.mouse.get_focused">
<big><b>pygame.mouse.get_focused</big></b><br><ul>
  <i>check if the display is receiving mouse input</i><br>
  <tt>pygame.mouse.get_focused(): return bool</tt><br>
<p>Returns true when the mouse is receiving mouse input events. This will only happen while working in windowed display systems. </p>
 &nbsp;<br> 
<br></ul>


<a name="pygame.mouse.set_cursor">
<big><b>pygame.mouse.set_cursor</big></b><br><ul>
  <i>set the image for the system mouse cursor</i><br>
  <tt>pygame.mouse.set_cursor(size, hotspot, xormasks, andmasks): return None</tt><br>
<p>When the mouse cursor is visible, it will be displayed as a black and white bitmap using the given bitmask arrays. The size is a sequence containing the cursor width and height. Hotspot is a sequence containing the cursor hotspot position. xormasks is a sequence of bytes containing the cursor xor data masks. Lastly is andmasks, a sequence of bytes containting the cursor bitmask data. </p>
<p>Width must be a multiple of 8, and the mask arrays must be the correct size for the given width and height. Otherwise an exception is raised. </p>
<p>See the <tt>pygame.cursor</tt> module for help creating default and custom masks for the system cursor. </p>
 &nbsp;<br> 
<br></ul>


<a name="pygame.mouse.get_cursor">
<big><b>pygame.mouse.get_cursor</big></b><br><ul>
  <i>get the image for the system mouse cursor</i><br>
  <tt>pygame.mouse.get_cursor(): return (size, hotspot, xormasks, andmasks)</tt><br>
<p>Get the information about the mouse system cursor. The return value is the same data as the arguments passed into <tt><a href="mouse.html#pygame.mouse.set_cursor">pygame.mouse.set_cursor</a></tt>. </p>
 &nbsp;<br> 
<br></ul>
<br></ul>

</body></html>