button_press_event for custom widget
- From: "Florian Schaefer" <listbox netego de>
- To: gtk-app-devel-list gnome org
- Subject: button_press_event for custom widget
- Date: 15 Nov 2004 13:18:25 CET
Hi,
I'm currently trying to write a wigedt to visualize some graphical data.
The widget is inited by the following funcitons:
GType
gtk_spect_vis_get_type ()
{
static GType spect_vis_type = 0;
if (!spect_vis_type)
{
static const GTypeInfo spect_vis_info =
{
sizeof (GtkSpectVisClass),
NULL,
NULL,
(GClassInitFunc) gtk_spect_vis_class_init,
NULL,
NULL,
sizeof (GtkSpectVis),
0,
(GInstanceInitFunc) gtk_spect_vis_init,
};
spect_vis_type = g_type_register_static (GTK_TYPE_DRAWING_AREA,
"GtkSpectVis", &spect_vis_info, 0);
}
return spect_vis_type;
}
static void
gtk_spect_vis_init (GtkSpectVis *spectvis)
{
GtkWidget *widget = NULL;
GdkPixmap *pixmap = NULL;
widget = gtk_drawing_area_new ();
gtk_widget_set_events (widget, GDK_EXPOSURE_MASK
| GDK_BUTTON_PRESS_MASK
| GDK_BUTTON_RELEASE_MASK
| GDK_POINTER_MOTION_MASK
| GDK_POINTER_MOTION_HINT_MASK);
gtk_widget_show (widget);
spectvis->draw = widget;
spectvis->pixmap = pixmap;
}
And the class_init looks like this:
static void
gtk_spect_vis_class_init (GtkSpectVisClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
parent_class = gtk_type_class (gtk_widget_get_type ());
object_class->destroy = gtk_spect_vis_destroy;
widget_class->expose_event = gtk_spect_vis_expose;
widget_class->size_request = gtk_spect_vis_size_request;
widget_class->configure_event = gtk_spect_vis_configure;
widget_class->button_press_event = gtk_spect_vis_button_press;
}
My problem is hat the following function never gets called:
static gboolean
gtk_spect_vis_button_press (GtkWidget *widget, GdkEventButton *event)
{
g_return_val_if_fail (GTK_IS_SPECTVIS (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
g_print ("button_press_event\n");
return TRUE;
}
Therefore my question is: What do I have to do that I can click into my
widget and receive the appropriate event?
Ciao
Florian
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]