Dropping a file onto TextArea
Posted
#1
(In Topic #1134)
Trainee
I am having a problem with a drop event that I hope someone can help with. I have simplified the problem to the following…
I have a form that contains only two controls; a TableView and a TextArea. The text area is set to allow drop by default.
When I drag a file off my desktop into the text area it catches the file name and allows me to open it and load the contents to the text area but it leaves the headings in the table view fixed in that I can no longer resize the heading by dragging them with the mouse pointer. Everything else about the table view works ok.
This is all the code in FMain.Class
Code
' Gambas class file
Public Sub Form_Open()
TableView1.Columns.Count = 2
TableView1.Rows.Count = 2
TableView1.Columns[0].Text = "Heading 1"
TableView1.Columns[1].Text = "Heading 2"
TableView1[0, 0].Text = "123456"
TableView1[0, 1].Text = "abcdefg"
End
Public Sub TextArea1_Drop()
TextArea1.Text = Drag.Data
End
Thank you for looking
Posted
Guru

Drag.Data for a file drop is a cr-lf terminated list and will look like this…
Code
file:///home/bonus/Desktop/gambas3.desktop\r\n
You should do something like this…
Code (gambas)
- sText = Drag.Paste("text/uri-list")[0]
- sText = Drag.Paste("text/plain")
- TextArea1.Text = sText
see the difference..
It is different if you use QT
(PS. to use QT you must set the textarea.Drop property to false in the IDE then set TextArea1.Drop = True in Form_Open() to override QT default drop behavior)
I have reported the bug to the boss and sent a test project.
I also found after the file drop if you drag some text onto the TextArea again the program crashes with a segfault.
Posted
Trainee
Made the changes you suggested and it works fine.
Posted
Regular

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>
1 guest and 0 members have just viewed this.


