Re: GTK3 -- query mouse pointer coordinates for keyboard input?

If you have a keyboard device, you can use gdk_device_get_associated_device() to return the paired mouse device.

On Fri, Jan 17, 2014 at 4:26 PM, Stefan Salewski <mail ssalewski de> wrote:
I recently ported a GTK2 application to GTK3

I had some working Ruby code like this for GTK2:

def distribute_events(pda, event)
if event.event_type == Gdk::Event::Type::KEY_PRESS
px, py = pda.get_user_coordinates(*pda.pointer)
px, py = pda.get_user_coordinates(event.x, event.y)

window.get_pointer() is deprecated in GTK3.

We should use

But for this function we need a reference to the pointing device, which
is not available from keyboard event.

Or in other words:
In GTK3-demo there is an Drawing_Area application where we can draw when
we held down the left mouse key: How can we draw a circle at the current
mouse position when we press 'C' key?

Best regards,

Stefan Salewski

gtk-list mailing list
gtk-list gnome org


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