Teststack.White Drag and Drop Issues

I'm having trouble dragging and dropping a control into another control. I had success in selecting both controls, but when I try to use:

Mouse.Instance.Location = dragControl.ClickablePoint;
Mouse.LeftDown();

Mouse.Instance.Location = dropControl.ClickablePoint;
Mouse.LeftUp();

      

No dragging occurs, the mouse moves. But control remains in its original place.

I have also tried using:

Mouse.Instance.DragAndDrop(dragItem, dragItem.ClickablePoint, dropItem, dropItem.ClickablePoint);

      

Still no luck.

I did some experimentation and one moment and got it to work, but I lost control of the resource that I found a workable solution in before (and I deleted my working code - lesson learned).

Any help would be appreciated!

Thanks in advance!

Update 6/15

Ok so I hacked this a bit. For some reason, it seems that the control is not actually being dragged. The mouse moves, but the control does not move with it.

+3


source to share


1 answer


Ok, I have no idea why the White DragAndDrop function is not working (or manually using leftDown, move, leftUp).

But I found a solution.

Essentially, I rewrote the white drag function with a delay between each step. So it looks like this:



guiObject.Click();
Mouse.LeftDown();

var stepCount = 10;
var stepAmount = (float) (guiObject.ClickablePoint.Y - targetObject.ClickablePoint.Y)/stepCount;

for (var i = 0; i < stepCount; i++)
{
    Mouse.Instance.Location = new Point(Mouse.Instance.Location.X, Mouse.Instance.Location.Y - stepAmount);
    Thread.Sleep(75); // I played around with the values and 75 seems to work without being too slow
}

Mouse.LeftUp();

      

Hope this helps anyone who may be facing this issue. I don't know why I needed to delay the delay, but it works.

+3


source







All Articles