GTK3 -- query mouse pointer coordinates for keyboard input?



I recently ported a GTK2 application to GTK3
(http://www.ssalewski.de/PetEd.html.en)

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)
else
px, py = pda.get_user_coordinates(event.x, event.y)

window.get_pointer() is deprecated in GTK3.

https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-get-pointer

We should use 

https://developer.gnome.org/gdk3/stable/gdk3-Windows.html#gdk-window-get-device-position

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




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