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
(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


_______________________________________________
gtk-list mailing list
gtk-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-list



--
  Jasper


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