@@ -15,13 +15,13 @@ When the display mode is set, the event queue will start receiving mouse
15
15
events. The mouse buttons generate ``pygame.MOUSEBUTTONDOWN `` and
16
16
``pygame.MOUSEBUTTONUP `` events when they are pressed and released. These
17
17
events contain a button attribute representing which button was pressed. The
18
- mouse wheel will generate ``pygame.MOUSEBUTTONDOWN `` and
19
- ``pygame.MOUSEBUTTONUP `` events when rolled. The button will be set to 4
20
- when the wheel is rolled up, and to button 5 when the wheel is rolled down.
21
- Whenever the mouse is moved it generates a ``pygame.MOUSEMOTION `` event. The
22
- mouse movement is broken into small and accurate motion events. As the mouse
23
- is moving many motion events will be placed on the queue. Mouse motion events
24
- that are not properly cleaned from the event queue are the primary reason the
18
+ mouse wheel will generate ``pygame.MOUSEBUTTONDOWN `` and
19
+ ``pygame.MOUSEBUTTONUP `` events when rolled. The button will be set to 4
20
+ when the wheel is rolled up, and to button 5 when the wheel is rolled down.
21
+ Whenever the mouse is moved it generates a ``pygame.MOUSEMOTION `` event. The
22
+ mouse movement is broken into small and accurate motion events. As the mouse
23
+ is moving many motion events will be placed on the queue. Mouse motion events
24
+ that are not properly cleaned from the event queue are the primary reason the
25
25
event queue fills up.
26
26
27
27
If the mouse cursor is hidden, and input is grabbed to the current display the
@@ -34,17 +34,17 @@ configured.
34
34
**Mouse Wheel Behavior in pygame 2 **
35
35
36
36
There is proper functionality for mouse wheel behaviour with pygame 2 supporting
37
- ``pygame.MOUSEWHEEL `` events. The new events support horizontal and vertical
38
- scroll movements, with signed integer values representing the amount scrolled
39
- (``x `` and ``y ``), as well as ``flipped `` direction (the set positive and
40
- negative values for each axis is flipped). Read more about SDL2
37
+ ``pygame.MOUSEWHEEL `` events. The new events support horizontal and vertical
38
+ scroll movements, with signed integer values representing the amount scrolled
39
+ (``x `` and ``y ``), as well as ``flipped `` direction (the set positive and
40
+ negative values for each axis is flipped). Read more about SDL2
41
41
input-related changes here `<https://wiki.libsdl.org/MigrationGuide#input >`_
42
42
43
- In pygame 2, the mouse wheel functionality can be used by listening for the
44
- ``pygame.MOUSEWHEEL `` type of an event (Bear in mind they still emit
43
+ In pygame 2, the mouse wheel functionality can be used by listening for the
44
+ ``pygame.MOUSEWHEEL `` type of an event (Bear in mind they still emit
45
45
``pygame.MOUSEBUTTONDOWN `` events like in pygame 1.x, as well).
46
- When this event is triggered, a developer can access the appropriate ``Event `` object
47
- with ``pygame.event.get() ``. The object can be used to access data about the mouse
46
+ When this event is triggered, a developer can access the appropriate ``Event `` object
47
+ with ``pygame.event.get() ``. The object can be used to access data about the mouse
48
48
scroll, such as ``which `` (it will tell you what exact mouse device trigger the event).
49
49
50
50
.. code-block :: python
@@ -57,19 +57,19 @@ scroll, such as ``which`` (it will tell you what exact mouse device trigger the
57
57
pygame.init()
58
58
screen = pygame.display.set_mode((640 , 480 ))
59
59
clock = pygame.time.Clock()
60
-
60
+
61
61
def main ():
62
62
while True :
63
63
for event in pygame.event.get():
64
64
if event.type == QUIT :
65
65
pygame.quit()
66
66
return
67
67
elif event.type == MOUSEWHEEL :
68
- print (event)
68
+ print (event)
69
69
print (event.x, event.y)
70
70
print (event.flipped)
71
71
print (event.which)
72
- # can access properties with
72
+ # can access properties with
73
73
# proper notation(ex: event.y)
74
74
clock.tick(60 )
75
75
@@ -86,23 +86,21 @@ scroll, such as ``which`` (it will tell you what exact mouse device trigger the
86
86
buttons. A true value means the mouse is currently being pressed at the time
87
87
of the call.
88
88
89
- Note, to get all of the mouse events it is better to use either
90
- ``pygame.event.wait() `` or ``pygame.event.get() `` and check all of those
89
+ To get all of the mouse events it is better to use either
90
+ ``pygame.event.wait() `` or ``pygame.event.get() `` and check all of those
91
91
events to see if they are ``MOUSEBUTTONDOWN ``, ``MOUSEBUTTONUP ``, or
92
- ``MOUSEMOTION ``.
92
+ ``MOUSEMOTION ``. Remember to call ``pygame.event.get() `` or ``pygame.event.pump() ``
93
+ before this function, otherwise it will not work as expected.
93
94
94
- Note, that on ``X11 `` some X servers use middle button emulation. When you
95
- click both buttons ``1 `` and ``3 `` at the same time a ``2 `` button event
96
- can be emitted.
95
+ To support five button mice, an optional parameter ``num_buttons `` has been
96
+ added in pygame 2. When this is set to ``5 ``, ``button4 `` and ``button5 ``
97
+ are added to the returned tuple. Only ``3 `` and ``5 `` are valid values
98
+ for this parameter.
97
99
98
- Note, remember to call ``pygame.event.get() `` before this function.
99
- Otherwise it will not work as expected.
100
+ .. note :: On ``X11`` some X servers use middle button emulation. When you
101
+ click both buttons ``1 `` and ``3 `` at the same time a ``2 `` button event
102
+ can be emitted.
100
103
101
- To support five button mice, an optional parameter ``num_buttons `` has been
102
- added in pygame 2. When this is set to ``5 ``, ``button4 `` and ``button5 ``
103
- are added to the returned tuple. Only ``3 `` and ``5 `` are valid values
104
- for this parameter.
105
-
106
104
.. versionchangedold :: 2.0.0 ``num_buttons`` argument added
107
105
108
106
.. ## pygame.mouse.get_pressed ##
@@ -113,18 +111,18 @@ scroll, such as ``which`` (it will tell you what exact mouse device trigger the
113
111
| :sg:`get_just_pressed() -> (left_button, middle_button, right_button, x1_button, x2_button)`
114
112
115
113
Very similar to :func: `pygame.mouse.get_pressed() `, returning a tuple
116
- of length 5 with the important difference that the buttons are
114
+ of length 5 with the important difference that the buttons are
117
115
True only in the frame they start being pressed. This can be convenient
118
116
for checking the buttons pressed "this frame", but for more precise results
119
- and correct ordering prefer using the pygame.MOUSEBUTTONDOWN event.
117
+ and correct ordering prefer using the `` pygame.MOUSEBUTTONDOWN `` event.
120
118
121
119
The result of this function is updated when new events are processed,
122
120
e.g. in :func: `pygame.event.get() ` or :func: `pygame.event.pump() `.
123
121
124
122
.. seealso :: :func:`pygame.mouse.get_just_released()`
125
123
126
124
::
127
-
125
+
128
126
if pygame.mouse.get_just_pressed()[0]:
129
127
print("LMB just pressed")
130
128
@@ -138,18 +136,18 @@ scroll, such as ``which`` (it will tell you what exact mouse device trigger the
138
136
| :sg:`get_just_released() -> (left_button, middle_button, right_button, x1_button, x2_button)`
139
137
140
138
Similar to :func: `pygame.mouse.get_pressed() `, returning a tuple
141
- of length 5 with the important difference that the buttons are
139
+ of length 5 with the important difference that the buttons are
142
140
True only in the frame they stop being pressed. This can be convenient
143
141
for checking the buttons released "this frame", but for more precise results
144
- and correct ordering prefer using the pygame.MOUSEBUTTONUP event.
142
+ and correct ordering prefer using the `` pygame.MOUSEBUTTONUP `` event.
145
143
146
144
The result of this function is updated when new events are processed,
147
145
e.g. in :func: `pygame.event.get() ` or :func: `pygame.event.pump() `.
148
146
149
147
.. seealso :: :func:`pygame.mouse.get_just_pressed()`
150
148
151
149
::
152
-
150
+
153
151
if pygame.mouse.get_just_released()[0]:
154
152
print("LMB just released")
155
153
@@ -258,7 +256,7 @@ scroll, such as ``which`` (it will tell you what exact mouse device trigger the
258
256
Get the information about the mouse system cursor. The return value contains
259
257
the same data as the arguments passed into :func: `pygame.mouse.set_cursor() `.
260
258
261
- .. note :: Code that unpacked a get_cursor() call into
259
+ .. note :: Code that unpacked a get_cursor() call into
262
260
``size, hotspot, xormasks, andmasks `` will still work,
263
261
assuming the call returns an old school type cursor.
264
262
@@ -285,7 +283,7 @@ scroll, such as ``which`` (it will tell you what exact mouse device trigger the
285
283
Sets the relative mouse mode state.
286
284
While the mouse is in relative mode, the cursor is hidden,
287
285
the mouse position is constrained to the window, and pygame
288
- will report continuous relative mouse motion even if the
286
+ will report continuous relative mouse motion even if the
289
287
mouse is at the edge of the window.
290
288
291
289
*This function will flush any pending mouse motion." *
0 commit comments