mirror of
https://github.com/1j01/textual-paint.git
synced 2024-12-22 06:11:37 +03:00
This is somewhat more reliable (maybe just due to the delay....)
This commit is contained in:
parent
2a7b4412e1
commit
b9503e44f4
@ -162,9 +162,20 @@ class PilotRecorder():
|
|||||||
if index is None:
|
if index is None:
|
||||||
steps_code += f"await pilot.click({selector!r}, offset=Offset({offset.x}, {offset.y}))\n"
|
steps_code += f"await pilot.click({selector!r}, offset=Offset({offset.x}, {offset.y}))\n"
|
||||||
else:
|
else:
|
||||||
steps_code += f"widget = pilot.app.query({selector!r})[{index!r}]\n"
|
# Strategy: click on the screen, offset by the widget's position.
|
||||||
# can't pass a widget to pilot.click, only a selector, or None
|
# steps_code += f"widget = pilot.app.query({selector!r})[{index!r}]\n"
|
||||||
steps_code += f"await pilot.click(offset=Offset({offset.x}, {offset.y}) + widget.region.offset)\n"
|
# # can't pass a widget to pilot.click, only a selector, or None
|
||||||
|
# steps_code += f"await pilot.click(offset=Offset({offset.x}, {offset.y}) + widget.region.offset)\n"
|
||||||
|
# Strategy: add a class to the widget, and click on that.
|
||||||
|
steps_code += f"""
|
||||||
|
# Click on widget disambiguated by index (selector {selector!r} matched multiple nodes)
|
||||||
|
await pilot.pause(0.5)
|
||||||
|
widget = pilot.app.query({selector!r})[{index!r}]
|
||||||
|
widget.add_class('pilot-click-target')
|
||||||
|
await pilot.click('.pilot-click-target')
|
||||||
|
widget.remove_class('pilot-click-target')
|
||||||
|
|
||||||
|
"""
|
||||||
elif isinstance(event, MouseMove):
|
elif isinstance(event, MouseMove):
|
||||||
# TODO: generate code for drags (but not extraneous mouse movement)
|
# TODO: generate code for drags (but not extraneous mouse movement)
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user