@@ -227,8 +227,8 @@ async def click(
227227 OutOfBounds: If the position to be clicked is outside of the (visible) screen.
228228
229229 Returns:
230- True if no selector was specified or if the click landed on the selected
231- widget, False otherwise .
230+ ` True` if no selector was specified or if the selected widget was under the mouse
231+ when the click was initiated. ` False` is the selected widget was not under the pointer .
232232 """
233233 try :
234234 return await self ._post_mouse_events (
@@ -284,8 +284,8 @@ async def double_click(
284284 OutOfBounds: If the position to be clicked is outside of the (visible) screen.
285285
286286 Returns:
287- True if no selector was specified or if the clicks landed on the selected
288- widget, False otherwise .
287+ ` True` if no selector was specified or if the selected widget was under the mouse
288+ when the click was initiated. ` False` is the selected widget was not under the pointer .
289289 """
290290 return await self .click (widget , offset , shift , meta , control , times = 2 )
291291
@@ -329,8 +329,8 @@ async def triple_click(
329329 OutOfBounds: If the position to be clicked is outside of the (visible) screen.
330330
331331 Returns:
332- True if no selector was specified or if the clicks landed on the selected
333- widget, False otherwise .
332+ ` True` if no selector was specified or if the selected widget was under the mouse
333+ when the click was initiated. ` False` is the selected widget was not under the pointer .
334334 """
335335 return await self .click (widget , offset , shift , meta , control , times = 3 )
336336
@@ -414,7 +414,7 @@ async def _post_mouse_events(
414414 elif isinstance (widget , Widget ):
415415 target_widget = widget
416416 else :
417- target_widget = app . screen .query_one (widget )
417+ target_widget = screen .query_one (widget )
418418
419419 message_arguments = _get_mouse_message_arguments (
420420 target_widget ,
@@ -434,6 +434,7 @@ async def _post_mouse_events(
434434 widget_at = None
435435 for chain in range (1 , times + 1 ):
436436 for mouse_event_cls in events :
437+ await self .pause ()
437438 # Get the widget under the mouse before the event because the app might
438439 # react to the event and move things around. We override on each iteration
439440 # because we assume the final event in `events` is the actual event we care
@@ -444,16 +445,17 @@ async def _post_mouse_events(
444445 if mouse_event_cls is Click :
445446 kwargs = {** kwargs , "chain" : chain }
446447
447- widget_at , _ = app .get_widget_at (* offset )
448+ if widget_at is None :
449+ widget_at , _ = app .get_widget_at (* offset )
448450 event = mouse_event_cls (** kwargs )
449451 # Bypass event processing in App.on_event. Because App.on_event
450452 # is responsible for updating App.mouse_position, and because
451453 # that's useful to other things (tooltip handling, for example),
452454 # we patch the offset in there as well.
453455 app .mouse_position = offset
454456 screen ._forward_event (event )
455- await self .pause ()
456457
458+ await self .pause ()
457459 return widget is None or widget_at is target_widget
458460
459461 async def _wait_for_screen (self , timeout : float = 30.0 ) -> bool :
0 commit comments