diff --git a/src/textual/pilot.py b/src/textual/pilot.py index 8b649e81c5..c387b25827 100644 --- a/src/textual/pilot.py +++ b/src/textual/pilot.py @@ -104,6 +104,7 @@ async def mouse_down( shift: bool = False, meta: bool = False, control: bool = False, + button: int = 1, ) -> bool: """Simulate a [`MouseDown`][textual.events.MouseDown] event at a specified position. @@ -121,6 +122,7 @@ async def mouse_down( shift: Simulate the event with the shift key held down. meta: Simulate the event with the meta key held down. control: Simulate the event with the control key held down. + button: The mouse button to press. Raises: OutOfBounds: If the position for the event is outside of the (visible) screen. @@ -134,7 +136,7 @@ async def mouse_down( [MouseMove, MouseDown], widget=widget, offset=offset, - button=1, + button=button, shift=shift, meta=meta, control=control, @@ -195,6 +197,7 @@ async def click( meta: bool = False, control: bool = False, times: int = 1, + button: int = 1, ) -> bool: """Simulate clicking with the mouse at a specified position. @@ -222,6 +225,7 @@ async def click( meta: Click with the meta key held down. control: Click with the control key held down. times: The number of times to click. 2 will double-click, 3 will triple-click, etc. + button: The mouse button to click. Raises: OutOfBounds: If the position to be clicked is outside of the (visible) screen. @@ -235,7 +239,7 @@ async def click( [MouseDown, MouseUp, Click], widget=widget, offset=offset, - button=1, + button=button, shift=shift, meta=meta, control=control, @@ -251,6 +255,7 @@ async def double_click( shift: bool = False, meta: bool = False, control: bool = False, + button: int = 1, ) -> bool: """Simulate double clicking with the mouse at a specified position. @@ -279,6 +284,7 @@ async def double_click( shift: Click with the shift key held down. meta: Click with the meta key held down. control: Click with the control key held down. + button: The mouse button to click. Raises: OutOfBounds: If the position to be clicked is outside of the (visible) screen. @@ -287,7 +293,9 @@ async def double_click( `True` if no selector was specified or if the selected widget was under the mouse when the click was initiated. `False` is the selected widget was not under the pointer. """ - return await self.click(widget, offset, shift, meta, control, times=2) + return await self.click( + widget, offset, shift, meta, control, times=2, button=button + ) async def triple_click( self, @@ -296,6 +304,7 @@ async def triple_click( shift: bool = False, meta: bool = False, control: bool = False, + button: int = 1, ) -> bool: """Simulate triple clicking with the mouse at a specified position. @@ -324,6 +333,7 @@ async def triple_click( shift: Click with the shift key held down. meta: Click with the meta key held down. control: Click with the control key held down. + button: The mouse button to click. Raises: OutOfBounds: If the position to be clicked is outside of the (visible) screen. @@ -332,7 +342,9 @@ async def triple_click( `True` if no selector was specified or if the selected widget was under the mouse when the click was initiated. `False` is the selected widget was not under the pointer. """ - return await self.click(widget, offset, shift, meta, control, times=3) + return await self.click( + widget, offset, shift, meta, control, times=3, button=button + ) async def hover( self,