@@ -77,7 +77,7 @@ def release(self, buttons):
77
77
"""Release the given mouse buttons.
78
78
79
79
:param buttons: a bitwise-or'd combination of ``LEFT_BUTTON``, ``MIDDLE_BUTTON``, and ``RIGHT_BUTTON``.
80
- """
80
+ """
81
81
self .report [0 ] &= ~ buttons
82
82
self .move (0 , 0 , 0 )
83
83
@@ -104,31 +104,35 @@ def click(self, buttons):
104
104
self .press (buttons )
105
105
self .release (buttons )
106
106
107
- def move (self , x_distance , y_distance , wheel_turn ):
107
+ def move (self , x = 0 , y = 0 , wheel = 0 ):
108
108
"""Move the mouse and turn the wheel as directed.
109
109
110
- :param x_distance : Move the mouse along the x axis. Negative is to the left, positive is to the right.
111
- :param y_distance : Move the mouse along the y axis. Negative is toward the user , positive is away from the user .
112
- :param wheel turn : Rotate the wheel this amount. Negative is toward the user, positive is away from the user.
110
+ :param x : Move the mouse along the x axis. Negative is to the left, positive is to the right.
111
+ :param y : Move the mouse along the y axis. Negative is upwards on the display , positive is downwards .
112
+ :param wheel: Rotate the wheel this amount. Negative is toward the user, positive is away from the user. The scrolling effect depends on the host .
113
113
:raises ValueError: if any argument is not in the range -127 to 127 inclusive.
114
114
115
115
Examples::
116
116
117
- # Move 100 to the left.
117
+ # Move 100 to the left. Do not move up and down. Do not roll the scroll wheel.
118
118
m.move(-100, 0, 0)
119
+ # Same, with keyword arguments.
120
+ m.move(x=-100)
119
121
120
122
# Move diagonally to the upper right.
121
- m.move(50, 20, 0)
123
+ m.move(50, 20)
124
+ # Same.
125
+ m.move(x=50, y=-20)
122
126
123
127
# Roll the mouse wheel away from the user.
124
- m.move(0, 0, 5 )
128
+ m.move(wheel=1 )
125
129
"""
126
- if (self ._distance_ok (x_distance )
127
- and self ._distance_ok (y_distance )
128
- and self ._distance_ok (wheel_turn )):
129
- self .report [1 ] = x_distance
130
- self .report [2 ] = y_distance
131
- self .report [3 ] = wheel_turn
130
+ if (self ._distance_ok (x )
131
+ and self ._distance_ok (y )
132
+ and self ._distance_ok (wheel )):
133
+ self .report [1 ] = x
134
+ self .report [2 ] = y
135
+ self .report [3 ] = wheel
132
136
self .hid_mouse .send_report (self .report )
133
137
else :
134
138
raise ValueError ('All arguments must be >= -127 and <= 127' )
0 commit comments