Gnome canvas item events



Hello,

I'm trying to catch events in a custom GnomeCanvasItem. I based my custom
item on GnomeCanvasRect (I simply collapsed GnomeCanvasRE and
GnomeCanvasRect into one item) and added an event handler.

The code seems to work fine, i.e. the event handler is called, but only
after any callbacks on the item are called first. For example

...
item_class->event = gnome_canvas_myitem_event;
...
static gint gnome_canvas_myitem_event (GnomeCanvasItem *item, GdkEvent *event);
{
	if(event->type == GDK_BUTTON_PRESS && event->button.button == 1)
	{
		g_print("GDK_BUTTON_PRESS from my item\n");
		return TRUE;
	}

	return FALSE;
}

when I create an instance of my custom item, I also attach a callback:

...
GnomeCanvasItem * item = gnome_canvas_item_new(group,
				     gnome_canvas_myitem_get_type(),
				     "x1", 90.0,
				     "y1", 40.0,
				     "x2", 280.0,
				     "y2", 100.0,
				     "fill_color_rgba", 0x3cb37180,
				     "outline_color", "orange",
				     "width_units", 4.0,
				     NULL));
...
gtk_signal_connect(GTK_OBJECT(item), "event",
		   (GtkSignalFunc) item_event,
		   NULL);
...
static gint
item_event(GnomeCanvasItem * item, GdkEvent * event, gpointer data)
{
	if(event->type == GDK_BUTTON_PRESS && event->button.button == 1)
	{
		g_print("GDK_BUTTON_PRESS from callback\n");
	}
	return FALSE;
}
...

Now when I run the code and click on the item I get

GDK_BUTTON_PRESS from callback
GDK_BUTTON_PRESS from my item

Is there any way to reverse this so that the item gets a change to handle
the event first?

Thanks,
Dirk Puis
Dirk Puis pi be






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