Drawingarea drag&drop
Posted
#1
(In Topic #503)
Regular

My problem is that with the drop event in the picturebox I can't get the x & y position in the picturebox..
It seems that when the mouse drag enters the picturebox the normal values of mouse.x & .y aren't available.
Any help would be appreciated.
Posted
Guru

I think that how you activate mouse data on controls. i could be wrong though
Posted
Regular

I'm making a small project to better show the problem.
Posted
Regular

An item selected from the gridview and dropped in the drawingarea draws the circle in the wrong place
Code
' Gambas class file v3.15.2
Private Const MIME_TYPE As String = "text/x-gambas-dragndrop-example"
Private iMouseX As Integer
Private iMouseY As Integer
Public Sub Form_Open()
Dim i As Integer
gdvTemp.Columns.Count = 1
gdvTemp.Rows.Count = 4
For i = 0 To 3
gdvTemp[i, 0].Text = "item " & i
Next
End
Public Sub gdvTemp_MouseDrag()
Dim hImage As Image
Dim sText As String
sText = gdvTemp[gdvTemp.RowAt(Mouse.Y), gdvTemp.ColumnAt(Mouse.X)].Text
hImage = New Image(32 + 8 + gdvTemp.Font.TextWidth(sText), 32, Color.Transparent)
Paint.Begin(hImage)
Paint.Font = gdvTemp.Font
Paint.Text(sText, 34, 0, hImage.Width, 32, Align.Left)
Paint.Fill
Paint.End
Drag.Icon = hImage.Picture
gdvTemp.Drag(sText, MIME_TYPE)
End
Public Sub DrawingArea1_Drop()
DrawingArea1.Refresh
End
Public Sub DrawingArea1_Draw()
Draw.Circle(iMouseX, iMouseY, 10)
End
Public Sub DrawingArea1_MouseMove()
iMouseX = Mouse.X
iMouseY = Mouse.Y
End
Posted
Guru

Perhaps try grabbing the info on MouseDown() and set picture on MouseUp() ?
Just a thought.
Posted
Guru

I am a little confused here. You say 'I wish to drag an item from a gridview to a picturebox' but your example uses a DrawingArea :? ?
Do you want to drag the text from a GridView Cell to the DrawingArea/PictureBox and put a circle around it?
Can you provide a little more explanation.
Posted
Regular

However, regarding the identification of the mouse coordinates (drop point), you have modify, as follows, this routine:
It is understood that you have to set the "DrawingArea1.Drop" Property to "<COLOR color="#800000">True</COLOR>".
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Regular

Perhaps the idea of drawing of a circle confuses the issue so how about dropping an icon in the drawing area instead but it must be at the drop point.
Thanks for all your thoughts on this.
Posted
Regular

Posted
Guru

<IMG src="https://www.cogier.com/gambas/Garden.png">
</IMG>Code (gambas)
- DrawingAreaGarden As DrawingArea
- .Width = 500
- .Height = 500
- .Text = "Bill's garden"
- .Arrangement = Arrange.Vertical
- .Padding = 5
- .Rows.Count = 0
- .Columns.Count = 1
- GridViewData[iLoop, 0].Text = sText[iLoop]
- .Background = Color.Green
- GridViewData.Drag(sDragText)
- Paint.Begin(DrawingAreaGarden)
- Paint.Fill
- Paint.Stroke
- Paint.End
Posted
Regular

Posted
Guru

waaay beyond my capabilities lol.
no notions are foolish, it's all just part of the game we play
Best of luck
Posted
Regular

Don't know why I didn't think of it.
Now I need to find a way of getting rid of those pesky japanese knotweeds!
1 guest and 0 members have just viewed this.


