pressAndHold

pressAndHold(objectOrName, x, y)

pressAndHold(objectOrName, x, y, dx, dy)

This function performs a press and hold operation on the specified objectOrName item—starting with the mouse at position x and y (in the objectOrName item's coordinates) and optionally moving the mouse by dx pixels horizontally and by dy pixels vertically if these offsets are specified. (Note that dx and dy are relative to the starting mouse position in QML scene coordinates, not in objectOrName item coordinates which is normally the case.)

The pressAndHold function is supported on objects of type QDeclarativeItem.

The press and hold operation performed by this function is similar to what the dragItemBy(objectOrName, x, y, dx, dy, modifierState, button) function does, except for the hold (the initial pause when the mouse is first pressed down). QML scenes support press and hold by using an invisible MouseArea item that is overlaid on top of one or more of the scene's QML items. Squish doesn't record actions for invisible items so for a press and hold it records the item at the mouse (or finger for touch screens) position that is actually under the MouseArea.

Other Object Types

For objects of type QQuickItem, you can use either longMouseClick(objectOrName, x, y, modifierState, button) or longMouseDrag(objectOrName, x, y, dx, dy, modifierState, button).

For other objects it should be possible to emulate the effect of pressAndHold() by using a combination of the following functions:

For example:

function main()
{
    //...

    mouseMove(waitForObject(":target_object_name"), 5, 5);
    mousePress(waitForObject(":target_object_name"));
    snooze(3);
    mouseRelease(waitForObject(":target_object_name"));

    //...
}

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.
The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

Search Results