Re: Gnome_canvas_item



On Friday, June 16, 2000, "Florent. Devin" <Florent.Devin@lifl.fr> wrote:
> 
> Loban Rahman a écrit :
> > 
> > > I'm using drag'n drop (thanks Renaud) from a button to a canvas.
> > > In my canvas I've draw some image (GnomeCanvasImage).
> > > The problem is that GnomeCanvasImage derived from GtkObject, and not
> > > GtkWidget. And the GtkObject don't have drag'n drop signal...
> > > How can I handle drag'n drop signals ?
> > > Have I to handle signal for the canvas and determine where I drop ?
> > 
> > GnomeCanvasImage is derived from GnomeCanvasItem, which handles
> > these signals.
> > 
> Which handle not these signals... cause GnomeCanvasItem is derived from
> GtkObject...

You have to set up an event callback for the GnomeCanvasItem, and check
for the GDK_BUTTON_PRESS and GDK_BUTTON_RELEASE events to grab and
release the item (with gnome_canvas_item_grab() and
gnome_canvas_item_ungrab() respectively).  Also, you'll want to update
the position of the item as the cursor moves around, so you should also
intercept the GDK_MOTION_NOTIFY event.

This isn't true drag-and-drop, per se, but it does an excellent job of
faking it.  In a nutshell, you mimic the motions of the cursor for the
duration of the drag, creating the _illusion_ of drag-and-drop.

Havoc Pennington's book has a snippet of code to demonstrate this:

  http://developer.gnome.org/doc/GGAD/z177.html

HTH,
John

-- 
dusk@ravendusk.org                            http://www.gnome.org
jsheets@codeweavers.com                  http://www.worldforge.org
               http://advogato.org/person/jsheets




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]