Strange drag and drop rectangles…

The screen shot below was taken as I was dropping Rows (from a ListBox) onto the Finder.

Why two rectangles, why this form and not a single (and tall) rectangle instead of two ?

The used code is:

[code]Function DragRow(drag As DragItem, row As Integer) As Boolean
Dim nRows, i as Integer
nRows=Me.ListCount-1

// The idea is to have a tall rectangle
Drag.AddItem(0,0,20,Me.RowHeight * nRows)

For i=0 to nRows
If Me.Selected(i) then
// Drag.AddItem(0,0,20,4)
Drag.Text = Drag.Text + Me.List(i) + EndOfLine //get text
End if
Next

Return True //allow the drag[/code]

The code comes from the docs; I have changed one line (to avoid as many clipping files as selected rows) and I added the Drag.AddItem near the top).

Also, may I create a Picture, paint the text from the selected Rows there and pass the Pict to be included below the Mouse at drag time (like the car demo) ?

I’m hungry and I have to go right now…

The DragItem supplied to DragRow is already initialized with the horizontal box representing the row being dragged. That’s default behavior.

For something different create your own DragItem, set it up, call Drag and return False from this event.

Thank you, I will try.

I have just note to add. I have seen dragitems appear more crisp if the width & height are not
odd pixels (on OSX as least).

[code]Function DragRow(drag As DragItem, row As Integer) As Boolean
// change to see a difference
dim crispDrag as boolean = false

dim rowText as Text = me.cell(row,0).ToText
dim p as Picture

if crispDrag then
dim w as integer = (me.Width+1) / 2
dim h as integer = (me.RowHeight +1) /2
p = new Picture(w2,h2)
else
p = new Picture(me.Width, me.RowHeight)
end if

dim g as Graphics = p.Graphics
g.ForeColor = &c0080FF00
g.FillRoundRect 0,0,g.Width,g.Height,g.Height,g.Height
g.ForeColor = Color.white
dim w as integer = xojo.math.ceil(g.StringWidth(rowText))
g.DrawString rowText,(g.Width-w)/2, g.TextAscent+(g.Height-g.TextHeight)/2
drag.DragPicture = p

drag.Drag
return true
End Function[/code]

Thanks Rob.

I replaced my code with yours… no clipping created (OS X, Xojo 2015r1), only one “Rectangle” (the drag) even if I select more than one Row to be filled in a Clipping.

I will try with 2016r1 this afternoon.

Funny, because Graphics.DrawPicture works with troubles if some variables are integer not doubles, but the given syntax is:

Graphics.DrawPicture ( Image as Picture, X as Integer, Y as Integer [,DestWidth as Integer ] [, DestHeight as Integer ] [, SourceX as Integer ] [, SourceY as Integer ] [, SourceWidth as Integer ] [, SourceHeight as Integer] )

I do not recall why nor the variable…