Please explain: leave/Notify handler picks up button presses?

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

 



Can anyone explain why the following code calls "leave_notify_handler"
when I press the mouse in the drawing area as well as when the mouse
leaves the drawing area?  (A full example is appended.)  I am using
GTK+-2.2.1 on Linux, kernel 2.2.25, glibc-2.1.3 .

  GtkWidget *drawing_area;
  drawing_area = gtk_drawing_area_new();
  gtk_widget_add_events
    (drawing_area,GDK_LEAVE_NOTIFY_MASK);
  g_signal_connect
    (drawing_area,
     "leave-notify-event",
     leave_notify_handler,
     NULL
     );

Regards, 

Jeremy Henty 


Complete code example: 

#include <stdio.h>
#include <gtk/gtk.h>

static void make_interface(void);
int main (int argc, char **argv)
{
  gtk_init(&argc,&argv);
  make_interface();
  gtk_main();
  return 0;
}

static GtkWidget *main_window_make(void);
static GtkWidget *drawing_area_make(void);
static void make_interface (void)
{
  GtkWidget *main_window, *drawing_area;
  main_window = main_window_make();
  drawing_area = drawing_area_make();
  gtk_container_add(GTK_CONTAINER(main_window),drawing_area);
  gtk_widget_show_all(main_window);
}

static void destroy_handler(void);
static GtkWidget *main_window_make(void)
{
  GtkWidget *main_window;
  main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title
    (GTK_WINDOW(main_window), "Enter/Leave bug");
  g_signal_connect
    (main_window, "destroy", destroy_handler, NULL);
  return main_window;
}

static void destroy_handler(void)
{
  gtk_main_quit();
}

static void leave_notify_handler(void);
static GtkWidget *drawing_area_make (void)
{
  GtkWidget *drawing_area;
  drawing_area = gtk_drawing_area_new();
  gtk_widget_add_events
    (drawing_area,GDK_LEAVE_NOTIFY_MASK);
  g_signal_connect
    (drawing_area,
     "leave-notify-event",
     leave_notify_handler,
     NULL
     );
  return drawing_area;
}

static void leave_notify_handler(void)
{
  printf("%s","Leave/Notify event\n");
}


[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux