Also not sure if this is the right list.
Probably it is better to do it using just swing without using native code. If
you want to use native code you would need to implement the native code in each
platform, so you will need to use functions specific to each platform, e.g
User32 will not be available in Linux or Mac.
In java 6 you already have the getLocationOnScreen() method on MouseEvent, so
you just need to get MouseEvent (by adding a mouse listener or mouse motion
listener) and call this method.
In previous version it might try translating the coordingates returned by the
MouseEvent to screen coordinates by using by calling getComponent() to get the
component, and call getLocationOnScreen() on the component to get its location
and use it to translate the point (this is assuming the component has not moved
since the event was generated, otherwise it might get wrong information, but if
this is unlikely to happen it might be ok for you)
Thanks,
Daniel
----- Original Message -----
From: Maurice Naftalin
To: use...@jna.dev.java.net
Cc: Maurice Naftalin
Sent: Tuesday, July 10, 2007 1:29 PM
Subject: [jna-users] Fwd: Getting cursor position for Mac, Linux?
Apologies if this is not the right list for this query. JNA has been
excellent for solving one particular problem I have in Win32 - getting
the cursor position in screen coordinates. I just added a declaration
of GetCursorPos to examples.win32.User32, and everything Just
Worked - thanks very much! My question now is whether (and how)
I can achieve the same effect for Mac and/or Linux in the same way,
or whether some of the work in User32 needs doing again for these
platforms.
Thanks in advance
Maurice