Skip to content

Commit 1c20709

Browse files
authored
Merge pull request #6397 from NSPC911-forks/pilot-also-allow-changing-button
fix(pilot): expose button
2 parents ac7ef91 + 83dc54b commit 1c20709

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/textual/pilot.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ async def mouse_down(
104104
shift: bool = False,
105105
meta: bool = False,
106106
control: bool = False,
107+
button: int = 1,
107108
) -> bool:
108109
"""Simulate a [`MouseDown`][textual.events.MouseDown] event at a specified position.
109110
@@ -121,6 +122,7 @@ async def mouse_down(
121122
shift: Simulate the event with the shift key held down.
122123
meta: Simulate the event with the meta key held down.
123124
control: Simulate the event with the control key held down.
125+
button: The mouse button to press.
124126
125127
Raises:
126128
OutOfBounds: If the position for the event is outside of the (visible) screen.
@@ -134,7 +136,7 @@ async def mouse_down(
134136
[MouseMove, MouseDown],
135137
widget=widget,
136138
offset=offset,
137-
button=1,
139+
button=button,
138140
shift=shift,
139141
meta=meta,
140142
control=control,
@@ -195,6 +197,7 @@ async def click(
195197
meta: bool = False,
196198
control: bool = False,
197199
times: int = 1,
200+
button: int = 1,
198201
) -> bool:
199202
"""Simulate clicking with the mouse at a specified position.
200203
@@ -222,6 +225,7 @@ async def click(
222225
meta: Click with the meta key held down.
223226
control: Click with the control key held down.
224227
times: The number of times to click. 2 will double-click, 3 will triple-click, etc.
228+
button: The mouse button to click.
225229
226230
Raises:
227231
OutOfBounds: If the position to be clicked is outside of the (visible) screen.
@@ -235,7 +239,7 @@ async def click(
235239
[MouseDown, MouseUp, Click],
236240
widget=widget,
237241
offset=offset,
238-
button=1,
242+
button=button,
239243
shift=shift,
240244
meta=meta,
241245
control=control,
@@ -251,6 +255,7 @@ async def double_click(
251255
shift: bool = False,
252256
meta: bool = False,
253257
control: bool = False,
258+
button: int = 1,
254259
) -> bool:
255260
"""Simulate double clicking with the mouse at a specified position.
256261
@@ -279,6 +284,7 @@ async def double_click(
279284
shift: Click with the shift key held down.
280285
meta: Click with the meta key held down.
281286
control: Click with the control key held down.
287+
button: The mouse button to click.
282288
283289
Raises:
284290
OutOfBounds: If the position to be clicked is outside of the (visible) screen.
@@ -287,7 +293,9 @@ async def double_click(
287293
`True` if no selector was specified or if the selected widget was under the mouse
288294
when the click was initiated. `False` is the selected widget was not under the pointer.
289295
"""
290-
return await self.click(widget, offset, shift, meta, control, times=2)
296+
return await self.click(
297+
widget, offset, shift, meta, control, times=2, button=button
298+
)
291299

292300
async def triple_click(
293301
self,
@@ -296,6 +304,7 @@ async def triple_click(
296304
shift: bool = False,
297305
meta: bool = False,
298306
control: bool = False,
307+
button: int = 1,
299308
) -> bool:
300309
"""Simulate triple clicking with the mouse at a specified position.
301310
@@ -324,6 +333,7 @@ async def triple_click(
324333
shift: Click with the shift key held down.
325334
meta: Click with the meta key held down.
326335
control: Click with the control key held down.
336+
button: The mouse button to click.
327337
328338
Raises:
329339
OutOfBounds: If the position to be clicked is outside of the (visible) screen.
@@ -332,7 +342,9 @@ async def triple_click(
332342
`True` if no selector was specified or if the selected widget was under the mouse
333343
when the click was initiated. `False` is the selected widget was not under the pointer.
334344
"""
335-
return await self.click(widget, offset, shift, meta, control, times=3)
345+
return await self.click(
346+
widget, offset, shift, meta, control, times=3, button=button
347+
)
336348

337349
async def hover(
338350
self,

0 commit comments

Comments
 (0)