mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-09 13:56:10 +00:00
17be3bfb2c
This makes the scrolling work for any qml type where the child supports scrolling. By default the cursor is positioned in the middle of the scrollable item and scroll in steps of 30px.
58 lines
1.2 KiB
Python
Executable File
58 lines
1.2 KiB
Python
Executable File
import time
|
|
|
|
import squish
|
|
|
|
|
|
def move(obj: object, x: int, y: int, dx: int, dy: int, step: int, sleep: float = 0):
|
|
while True:
|
|
if x > dx:
|
|
x -= step
|
|
if x < x:
|
|
x = dx
|
|
elif x < dx:
|
|
x += step
|
|
if x > dx:
|
|
x = dx
|
|
if y > dy:
|
|
y -= step
|
|
if y < dy:
|
|
y = dy
|
|
elif y < dy:
|
|
y += step
|
|
if y > dy:
|
|
y = dy
|
|
squish.mouseMove(obj, x, y)
|
|
time.sleep(sleep)
|
|
if x == dx and y == dy:
|
|
break
|
|
|
|
|
|
def press_and_move(
|
|
obj,
|
|
x: int,
|
|
y: int,
|
|
dx: int,
|
|
dy: int,
|
|
mouse: int = squish.MouseButton.LeftButton,
|
|
step: int = 1,
|
|
sleep: float = 0
|
|
):
|
|
squish.mouseMove(obj, x, y)
|
|
squish.mousePress(obj, x, y, mouse)
|
|
move(obj, x, y, dx, dy, step, sleep)
|
|
squish.mouseRelease(mouse)
|
|
time.sleep(1)
|
|
|
|
def scroll(
|
|
obj,
|
|
x: int,
|
|
y: int,
|
|
dx: int,
|
|
dy: int,
|
|
steps: int = 1,
|
|
sleep: float = 0
|
|
):
|
|
for _ in range(steps):
|
|
squish.mouseWheel(obj, x, y, dx, dy, squish.Qt.NoModifier)
|
|
time.sleep(sleep)
|