Widening a Column using dragDrop()

Asked by sandra hulme

I am wondering how to widen a column on a grid control.

I found a positional value for my 'colWidth' variable on the column header then used dragdrop(colWidth.x+70, colWidth.y), but the column got narrower, just as it did when I used dragdrop(colWidth.x-70, colWidth.y).

Please can you tell me the correct way to widen a column.

Thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

dragDrop(from, to) needs 2 parameters. The first one is the location that is clicked and dragged and the second is the target point, where the mouse is moved and released.

So your example should be like this:

from = colWidth # should be a Region, Match or Location object
to = Location(from.x+70, from.y) # a new Location object
dragDrop(from, to)

or shorter:
dragDrop(colWidth, Location(colWidth.x+70, colWidth.y))

Revision history for this message
sandra hulme (sandra-hulme) said :
#2

Hi RaiMan,

 I have tried two things:

colWidth = find("Column Headings.png")

dragDrop(colWidth, Location(colWidth.x+70, colWidth.y))

and

colWidth = find("Column Headings.png")

dragDrop(colWidth, [colWidth.x+70, colWidth.y]) (this is the code I should have given you in my previous post)

but the column width always narrows, in fact the column collapses all together, even if I just decide to move 10 instead of 70.

I am wondering if there is a bug here?

Thanks

Revision history for this message
Best RaiMan (raimund-hocke) said :
#3

--1. dragDrop accepts both a 2-item list or a tuple as second parameter (I looked into the code and will change the docs).

a more elegant version would yet be:
dragDrop(colWidth, colwidth.getCenter().right(70))

--2.
No this is not a bug. dragDrop() does not work as expected in all situations due to internal timing of the subsequent mouse actions.

So try your own dragDrop and control the internal timing:

myDD(from, to): # to has to be a Location object!
   mouseMove(from); wait(0.5)
   mouseDown(Button.LEFT); wait(0.5)
   mouseMove(to); wait(0.5)
   mouseUp()

usage:
myDD(colWidth, colwidth.getCenter().right(70))

Comment: some apps have some internal waiting time before they accept a mouseover to be meant for them ;-). So experiment with the timing

Revision history for this message
sandra hulme (sandra-hulme) said :
#4

Hi

Thanks for the reply. I have been put onto another activity until tomorrow afternoon, but should then be able to try out your suggestion.

Revision history for this message
sandra hulme (sandra-hulme) said :
#5

Hi RaiMan

Suggestion 1 with getCenter() worked just as I wanted, but thanx for the custom function as well which may also come in useful if I hit further problems.

Thanks again!