One GnomeCanvasPixbuf, Many Events

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

 



Hello,

I am using the GnomeCanvasPixbuf canvas item to display a pixmap image.
I would like to generate different events based on the location on the
image where the user clicks. (Using a bunch of smaller images is not
desirable.) 

My original plan was to find the x and y coordinates of certain areas on
the image and then use a switch statement in the callback to generate
different results based on where the user click. However, the code I
wrote to find the x and y coordinates is generating some strange
results:

event_cb(GnomeCanvasItem *item, GdkEvent *event, gpointer data)
{

  double item_x, item_y;
  double root_x, root_y;

  item_x = event->button.x;
  item_y = event->button.y;
  root_x = event->button.x_root;
  root_y = event->button.y_root;
  

  if (event->type == GDK_BUTTON_PRESS)
    {  
      g_print("x1: %d, y1: %d \n", item_x, item_y);  
      g_print("x2: %d, y2: %d \n", root_x, root_y);  
    }

}

x1: 5793576, y1: 0
x2: 5802544, y2: 0
x1: 5793576, y1: 0
x2: 5860128, y2: 0
x1: 5793576, y1: 0
x2: 5860128, y2: 0
x1: 5793576, y1: 0
x2: 5861648, y2: 0

No matter where I click y is always 0? What am I missing here? Is there
a better way to do what I'm trying to do?

Thanks,
Catherine




_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

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

  Powered by Linux