[Gambas-user] File Chooser Drag and Drop
Bruce Steers
bsteers4 at gmail.com
Sun Jul 17 11:42:42 CEST 2022
On Sun, 17 Jul 2022 at 10:04, Bruce Steers <bsteers4 at gmail.com> wrote:
>
>
> On Sun, 17 Jul 2022 at 09:58, Bruce Steers <bsteers4 at gmail.com> wrote:
>
>>
>>
>> On Sun, 17 Jul 2022 at 03:28, sbungay <sbungay at smartsonsite.com> wrote:
>>
>>> Using the file chooser I want to drag one of the files from it
>>> (represented by its icon) to a text area and on dropping it have the
>>> text area load the file. Can't seem to get this to work, anyone have an
>>> example project I can examine?
>>>
>>
>> I just did this...
>>
>> https://gitlab.com/bsteers4/gambas/-/commit/51330ea23b08922593741daba56789e820329ca3
>>
>> Now i can turn on Dragging of file paths/names in DirChooser and
>> FileChooser.
>>
>> The bad news is the Choosers are not so easy to import as they use
>> various different class files from gb.form
>> Also i've only supported dragging/dropping the text as text/plain.
>> Not sure if it helps you? You can see the code needed but you'll have to
>> figure out how to import the Choosers into your own project.
>>
>
> Maybe Benoit could do something similar (but better coding of course ;) )
> I do not trust my understanding of the Drag method and checking
> Drag.Pending and exactly what to do.
> I could need more/better handling than..
>
>
>
>
>
>
>
> *Public Sub fvwChoose_MouseMove() If Not $bDragFiles Then Return If
> Mouse.Left Then If Drag.Pending Then Return
> fvwChoose.Drag(GetPath(), "text/plain") EndifEnd*
>
> Respects
> BruceS
>
AHA , I was wrong..
FileChooser and DirChooser already have the properties .FileView and
.DirView
With that you can access the internal respective views.
So the attached app works okay allowing Dragging from the file part of the
filchooser...
*' Gambas class filePublic Sub FView_MouseMove() If Mouse.Left Then If
Drag.Pending Then Return
FileChooser1.FileView.Drag(FileChooser1.FileView.Path, "text/plain")
EndifEndPublic Sub Form_Open() Object.Attach(FileChooser1.FileView, Me,
"FView")EndPublic Sub TextBox1_Drop() TextBox1.Text = Drag.DataEnd*
Wishing well
BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20220717/0b15e712/attachment.htm>
More information about the User
mailing list