# \[eggPlant Functional\] DoubleClick and Drag

**URL:** <https://forums.eggplantsoftware.com/t/eggplant-functional-doubleclick-and-drag/1863>\
**Category:** Eggplant Examples\
**Created:** [January 29, 2008, 3:34pm UTC](https://forums.eggplantsoftware.com/t/eggplant-functional-doubleclick-and-drag/1863 "2008-01-29T15:34:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SenseTalkDoug](https://forums.eggplantsoftware.com/user_avatar/forums.eggplantsoftware.com/sensetalkdoug/32/88_2.png) [@SenseTalkDoug](https://forums.eggplantsoftware.com/u/SenseTalkDoug)\
**Post date:** [January 29, 2008, 3:34pm UTC](https://forums.eggplantsoftware.com/t/eggplant-functional-doubleclick-and-drag/1863/1 "2008-01-29T15:34:28Z")

</div>

A customer recently asked: “I need to be able to double-click without releasing the mouse button and drag to another point on the screen. I just need a way to tell Eggplant not to release the mouse on the double-click.”

Eggplant’s DoubleClick command makes double-clicking easy but it doesn’t have any option to keep the mouse button down at the end. For that you’ll need to “roll your own” using the low-level MouseButtonDown and MouseButtonUp commands. The trick is to get the timing right for the double click, something that DoubleClick takes care of for you. The DoubleClick command includes a built-in delay between each mouse down and mouse up, and a different delay between the first and second clicks. Fortunately those delays are available as global properties in a script, so it’s pretty easy to get the desired result.

Here is a script that will do the job. Create a script with the name DoubleClickDrag and copy this code into it:

```auto
params dragImage -- the starting image or location

moveTo dragImage -- first move the mouse
put the remoteWorkInterval into origRWI -- save RWI
set the remoteWorkInterval to 0 -- take control of timing
mouseButtonDown 1 -- put the left button down
wait the mouseClickDelay
mouseButtonUp 1 -- let it up
wait the mouseDoubleClickDelay
mouseButtonDown 1 -- leave it down this time
set the remoteWorkInterval to origRWI -- restore RWI

```

With this script in your suite (or in a Helper suite) you can now use a DoubleClickDrag command in your scripts exactly the same way you would use Eggplant’s built-in Drag command:

```auto
DoubleClickDrag "dragStart"
Drop "dragFinish"

```

Notice that the DoubleClickDrag script carefully saves and restores the setting of the RemoteWorkInterval. The RWI is an important timing parameter in Eggplant that keeps it from sending events faster than the SUT can handle them. In this case it would slow things down too much for the double click to work properly, so we set it temporarily to zero. It’s important to restore it to its original value at the end so the rest of the script will work properly.

---

<div class="post-metadata">

**Author:** ![Todd](https://forums.eggplantsoftware.com/letter_avatar_proxy/v4/letter/t/fbc32d/32.png) [@Todd](https://forums.eggplantsoftware.com/u/Todd)\
**Post date:** [May 13, 2008, 12:42pm UTC](https://forums.eggplantsoftware.com/t/eggplant-functional-doubleclick-and-drag/1863/2 "2008-05-13T12:42:41Z")

</div>

```auto
mouseButtonDown 1 -- put the left button down 
wait the mouseClickDelay 
mouseButtonUp 1 -- let it up

```

with a

```auto
Click

```

command?

---

<div class="post-metadata">

**Author:** ![SenseTalkDoug](https://forums.eggplantsoftware.com/user_avatar/forums.eggplantsoftware.com/sensetalkdoug/32/88_2.png) [@SenseTalkDoug](https://forums.eggplantsoftware.com/u/SenseTalkDoug)\
**Post date:** [May 15, 2008, 7:50pm UTC](https://forums.eggplantsoftware.com/t/eggplant-functional-doubleclick-and-drag/1863/3 "2008-05-15T19:50:05Z")

</div>

Yes, doing a simple “Click” command should achieve the same thing as those three lines in my script. I wrote it all out to make it clear exactly what actions are being sent to the SUT, but it should give the same result. (For those who aren’t aware, a “Click” command with no parameters will simply click the mouse at its current location)
