How to unfocus a canvas item?



Hello!

I want to focus (in order to get keyboard events) and unfocus some canvas
items when the mouse enter and leaves. To focus is easy
(gnome_canvas_item_grab_focus), but how do I "unfocus" them?. I mean, I
will be glad if I would know how to focus the main window when the
mouse leaves a canvas item.

( if this is a very basic GTK question, just kick me gently =) )

Basically, the following is what I have in the "event" signal callback on 
all my canvas items:



GtkWidget *window;  /* This is the main window. */

/* ... */

static gint
item_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
{
  /* ... */

  switch (event->type) {

  case GDK_KEY_PRESS:
    printf ("ouch\n");
    break;

  case GDK_ENTER_NOTIFY:
    printf ("hello\n");
    fflush (stdout);
    gnome_canvas_item_grab_focus (item);
    break;

  case GDK_LEAVE_NOTIFY:
    printf ("bye\n");
    fflush (stdout);
    /* XXX None of the following works, the last focused canvas item
           keep the focus */
    /* gtk_widget_grab_focus (window); */
    /* gtk_window_activate_focus (GTK_WINDOW (window)); */
    break;

  /* ... */

  default:
    break;
  }

  return FALSE;
}


-- 
Arturo Tena
arturo@directmail.org



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