Re: Beginners question abour events



Murray Cumming wrote:
On Sun, 2004-02-29 at 17:03, Douglas Phillipson wrote:

I can't seem to find why you return TRUE, or FALSE at the end of an event routine like:

static gboolean
button_press_event( GtkWidget *widget, GdkEventButton *event )
{
  if (event->button == 1 && pixmap != NULL)
      draw_brush (widget, event->x, event->y);

  return TRUE;
}

What happens if you return FALSE when you should be returning TRUE?
How do you know what you should be returning?


Here's the gtkmm version of the explanation:
http://www.gtkmm.org/gtkmm2/docs/tutorial/html/apbs06.html


I understand what the difference is between returning TRUE and FALSE in a handler now (thankyou for the link). Now how do you tell which you should use? Example code I see like:

-------------------------------------------------------------
static gboolean
expose_event (GtkWidget * widget, GdkEventExpose * event)
{
  gdk_draw_drawable (widget->window,
             widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
             pixmap,
             event->area.x, event->area.y,
             event->area.x, event->area.y,
             event->area.width, event->area.height);

  return FALSE;
}
-------------------------------------------------------------
then there is:
-------------------------------------------------------------
static gboolean
button_press_event (GtkWidget * widget, GdkEventButton * event)
{
  if (event->button == 1 && pixmap != NULL) {
    draw_brush (widget, event->x, event->y);
  }

  return TRUE;
}
-------------------------------------------------------------
Why is the expose event returning FALSE? If this implies something else must be done in the event mechanism, what is remaining? Where might this be documented?

The button press event seems to be done so it returns TRUE. Is there something else I could do, or the gtk/gdk system would/could do with button events if I returned FALSE?

Thanks

Doug P





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