Re: Get position of cursor in widget?



Le lundi 16 juillet 2007 12:50, charlesvpacker a écrit :
I'm a GTK newbie who has successfully taken the very first
steps toward building a custom image processing application.
I've figured out how to read and display an image using
a GtkImage and GtkPixbuf. I've also modified a block of pixels
in the existing pixbuf and updated the displayed image
via gtk_image_set_from_pixbuf. Now I want to get the pixel
position of the mouse cursor resting on the image. I don't recall
seeing a GTK tutorial on capturing pointer position or motion.
Could somebody, um, point me to one?


If you want this from within a mouse event handler, you can use the 
(x,y) and (x_root,y_root) members provided by all the mouse event 
types. The first pair gives the position of the mouse relative to the 
event window and the second the position relative to the screen origin. 

If you're not in a handler, you still have gdk_window_get_pointer() and 
gdk_display_get_pointer(). See the Gdk reference manual for more infos 
(sections 'Event structures', 'Windows' and 'Display').

-- 
Cédric Lucantis



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