1. pygame
  2. pygame
  3. pygame


pygame / docs / ref / pygame_mouse.html

<body bgcolor=#dddddd text=#333377 link=#7777bb vlink=#7777bb>

<table border=0 width=100% cellpadding=0 cellspacing=0 bgcolor=#f5f5f5><tr valign=top>
<td rowspan=2><table border=0 cellpadding=5 cellspacing=0 bgcolor=#333377>
<tr height=86 align=left><td valign=middle><font color=#ffffff size=+5>
	<a href=../index.html><font size=+5 color=#ffffff><i><b>
<td valign=middle><tt><font color=#dddddd><br>
</td></tr></table></td><td width=100% align=center valign=middle>

	<a href=http://pygame.seul.org>Home</a> &nbsp;||&nbsp;
	<a href=../index.html>Help Contents</a> &nbsp;||

|| <a href=CD.html>CD</a> || 
<a href=Channel.html>Channel</a> || 
<a href=Font.html>Font</a> || 
<a href=Joystick.html>Joystick</a> || 
<a href=Rect.html>Rect</a> || 
<a href=Sound.html>Sound</a> || 
<a href=Surface.html>Surface</a> ||<br>
|| <a href=pygame.html>pygame</a> || 
<a href=pygame_cdrom.html>cdrom</a> || 
<a href=pygame_constants.html>constants</a> || 
<a href=pygame_display.html>display</a> || 
<a href=pygame_event.html>event</a> || 
<a href=pygame_font.html>font</a> || 
<a href=pygame_image.html>image</a> ||<br>
|| <a href=pygame_joystick.html>joystick</a> || 
<a href=pygame_key.html>key</a> || 
<a href=pygame_mixer.html>mixer</a> || 
<a href=pygame_mixer_music.html>mixer_music</a> || 
<a href=pygame_mouse.html>mouse</a> || 
<a href=pygame_surfarray.html>surfarray</a> || 
<a href=pygame_time.html>time</a> ||<br>

<h2 align=center>pygame.mouse</h2>
Contains routines for dealing with the mouse. All mouse events
are retrieved through the pygame.event module. The mouse module
can be used to get the current state of the mouse. It can also be
used to set the state of the system cursor.
If you hide the mouse cursor with pygame.mouse.set_visible(0) and
lock the mouse focus to your game with pygame.event.set_grab(1),
the hidden mouse will be forced to the center of the screen. This
will help your relative mouse motions keep from getting stuck on
the edges of the screen.


<tr><td><a href=#get_cursor>get_cursor</a></td><td> -
get mouse cursor data</td></tr>

<tr><td><a href=#get_focused>get_focused</a></td><td> -
state of mouse input focus</td></tr>

<tr><td><a href=#get_pos>get_pos</a></td><td> -
gets the cursor position</td></tr>

<tr><td><a href=#get_pressed>get_pressed</a></td><td> -
state of the mouse buttons</td></tr>

<tr><td><a href=#get_rel>get_rel</a></td><td> -
gets the movement of the mouse</td></tr>

<tr><td><a href=#set_cursor>set_cursor</a></td><td> -
state of shape of the mouse cursor</td></tr>

<tr><td><a href=#set_pos>set_pos</a></td><td> -
moves the cursor position</td></tr>

<tr><td><a href=#set_visible>set_visible</a></td><td> -
show or hide the mouse cursor</td></tr>



<a name=get_cursor><font size=+2><b>get_cursor
</b></font><br><font size=+1><tt>
pygame.mouse.get_cursor() -> size, hotspot, xormasks, andmasks
The mouse cursor data is the same as those passed into set_cursor.

<a name=get_focused><font size=+2><b>get_focused
</b></font><br><font size=+1><tt>
pygame.mouse.get_focused() -> bool
Returns true when the application is receiving the mouse input

<a name=get_pos><font size=+2><b>get_pos
</b></font><br><font size=+1><tt>
pygame.mouse.get_pos() -> x, y
Returns the current position of the mouse cursor. This is the
absolute mouse position on the screen.

<a name=get_pressed><font size=+2><b>get_pressed
</b></font><br><font size=+1><tt>
pygame.mouse.get_pressed() -> button1, button2, button3
This will return a small sequence containing the pressed state of
the mouse buttons.

<a name=get_rel><font size=+2><b>get_rel
</b></font><br><font size=+1><tt>
pygame.mouse.get_rel() -> x, y
Returns the total distance the mouse has moved since your last
call to <u>get_rel()</u>. On the first call to get_rel the movement will
always be 0,0.
When the mouse is at the edges of the screen, the relative
movement will be stopped. See mouse_visible for a way to resolve

<a name=set_cursor><font size=+2><b>set_cursor
</b></font><br><font size=+1><tt>
pygame.mouse.set_cursor(size, hotspot, xormasks, andmasks) -> None
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 with 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.
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.

<a name=set_pos><font size=+2><b>set_pos
</b></font><br><font size=+1><tt>
pygame.mouse.set_pos(pos) -> None
Moves the mouse cursor to the specified position. This will
generate a MOUSEMOTION event on the input queue. The pos argument
is a 2-number-sequence containing the desired x and y position.

<a name=set_visible><font size=+2><b>set_visible
</b></font><br><font size=+1><tt>
pygame.mouse.set_visible(bool) -> bool
Shows or hides the mouse cursor. This will return the previous
visible state of the mouse cursor.
Note that when the cursor is hidden and the application has
grabbed the input. pygame will force the mouse to stay in the
center of the screen. Since the mouse is hidden it won't matter
that it's not moving, but it will keep the mouse from the edges
of the screen so the relative mouse position will always be true.