A dragitem has a picture property.
If I set that in the dragrow event of a listbox, the dragging doesnt get a picture, just a rectangle
Is picture possible when dragging listbox rows?
(testing on MacOs Sierra at the moment)
A dragitem has a picture property.
If I set that in the dragrow event of a listbox, the dragging doesnt get a picture, just a rectangle
Is picture possible when dragging listbox rows?
(testing on MacOs Sierra at the moment)
I’m getting the same result on Mac 10.11, perhaps it’s an OS issue?
Windows users?
How do you set your DragPicture? This works fine for me. The only problem I get is that the picture now and then changes it’s x value.
In DragRow, I do this:
drag.text=Me.List(row) //store the text
drag.picture = unit16 //allocate a picture
Then when the dragging is happening, I get a hollow rectangle which is the size of the row.
You want to display an image while draging a Text ?
Strange.
I tested that sometimes ago, but the image was a drawing of the Listbox Rows (text).
There is an example that displays the displayed old car while draging it to the Finder.
I will post code when I will find the project (its 22:20 here, so it can be tomorrow).
Edit: the problem is that macOS search function cannot read inside a Xojo project (xojo_binary_project). I can only search with keywords (drag text picture )
I do this in dragrow event of the listbox and it works fine :
(my icon is 52x64 sized)
dim i,nb,mx,my as integer
dim p as Picture
' offsets the mouse from the control top-left
mx = me.MouseX - me.Left
my = me.MouseY - me.Top
p = new Picture (52, 64, 32)
p.Graphics.DrawPicture( <your-icon-here>, 0, 0)
drag = new DragItem( self, mx, my, 52, 64, p)
drag.Drag
Return true
[quote=318604:@Emile Schwarz]You want to display an image while draging a Text ?
[/quote]
I do this too : I display an icon with a red circle and inside the number of rows you’re dragging in a white text.
Well, yes…
The user is dragging ‘a thing’ even if it does have some descriptive text.
In my case, ‘a person’ from place to place.
Interesting. This works now.
The difference seems to be that the documentation doesn’t create the new drag item (and that’s what I had referenced) whereas your code creates a new drag item, and replaces the one from the event.
Edit: In fact, the documentation wording implies that we should assign the values to the drag item the event provides.
More interesting:
If I create a new dragitem instead of using the one supplied as a parameter, I get a picture.
But the dragover event stops firing, so I dont get any indication of which row will receive the dropped item.
So I get a picture and no dropping feedback, or no picture and rows highlight as the dragover fires.
Dragover event:
dim rownum as integer
rownum = me.RowFromXY(x,y)
me.listindex = rownum
[quote=318608:@Jeff Tullin]Well, yes…
The user is dragging ‘a thing’ even if it does have some descriptive text.
In my case, ‘a person’ from place to place.[/quote]
It is your right
and if I do that I cannot criticize anyone !
It is a good idea, I only needed a good use to finalize my test (and remember where I put it).
Note to self: Emile, youd better standardize the place you save your Xojo work, test, projects, ideas to develop and so on
Solved:
Dont use .Picture
Use .dragpicture of the drag parameter.
And return true.
No need to instantiate a new dragitem, or work out the mouse offsets.
We all overlooked that one!
This works very nicely…
dim p as new picture (me.width, me.RowHeight,32)
p.graphics.drawpicture me.rowpicture(me.listindex), 4, 2
p.graphics.textsize = 14
p.graphics.drawstring me.list(row), 28,16
drag.dragpicture = p
return true