Re: button_press_event for custom widget



On 15 Nov 2004 13:18:25 CET, Florian Schaefer <listbox netego de> wrote:
Hi,

I'm currently trying to write a wigedt to visualize some graphical data.

The widget is inited by the following funcitons:
[...]

static void
gtk_spect_vis_init (GtkSpectVis *spectvis)
{
[...]
  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);
[...]
}

Why are you creating a GtkDrawingArea ?, this widget already *is* a
drawing area, "events" on this widget come from the gdk layer from
`GTK_WIDGET(widget)->window', so usually you need to do
gtk_widget_set/add_events (widget, event_mask), in the init function:

gtk_spect_vis_init (GtkSpectVis *spectvis)
{
    GtkWidget *widget = GTK_WIDGET (spectvis);
    gtk_widget_add_events (widget, GDK_BUTTON_PRESS_MASK);
}

Cheers,
                                             -Tristan



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