[Gambas-user] Problems with some events

José Luis Redrejo jredrejo at ...626...
Sat Nov 3 16:49:22 CET 2007


2007/11/1, Benoit Minisini <gambas at ...1...>:
>
> On mercredi 31 octobre 2007, José Luis Redrejo wrote:
> >
> > So,  how could I get the information of a dropped file over a FileView
> > control?
> > That's a very typical use of a "FileView" in an application: dragging
> and
> > dropping files from Nautilus o Konqueror to add files to a directory.
> >
> > Now it's possible to do it with gtk, but reading your answer I guess
> you're
> > going to modify it to behave as in qt, where these events can not be
> > reached.
> >
> > Regards.
>
> You must add this feature directly to the FileView control, by modifying
> its
> source code.
>
> Or you can inherits FileView, try to find its child IconView / ListView
> (not
> too difficult, use FileView.Children[0]) , and use the Observer class to
> catch Drag & Drop events sent to them.
>
> --8<-----------------------------------------------------------------
> 'CLASS MyFileView
>
> INHERITS FileView
>
> PRIVATE $hObserver AS Observer
>
> PUBLIC SUB _new()
>
>   $hObserver = NEW Observer(ME.Children[0]) AS "TheIconView"
>
> END
>
> PUBLIC SUB TheIconView_Drop()
>
>   PRINT Drag.Data
>
> END
> --8<-----------------------------------------------------------------
>
> You have more work if you want to now which icon was specifically hit by
> the
> drop.
>
> Note that at the moment, gb.gtk IconView cannot returns the needed
> (X,Y,W,H)
> coordinates of an icon. I didn't find how to do that in GTK+, whereas the
> API
> allows that for TreeView items.
>
> Regards,
>

 it works as you said (with 1.9.90, with 1.9.50 I can not get the children
of MyFileView), there was only one sentence missing in the _new procedure:
me.Children[0].drop=true
 to make it work.

In fact, I didn't need to create a new class subclassing FileView, just
adding the observer to an existing FileVIew in the form is enough.

Thanks very much for your support and ideas. It's at least as valuable as
your developing work.
Regards.



More information about the User mailing list