5 messages in net.java.dev.jna.usersRe: [jna-users] Fwd: Getting cursor p...
FromSent OnAttachments
Maurice NaftalinJul 10, 2007 9:29 am 
Daniel KaufmannJul 10, 2007 10:21 am 
Timothy WallJul 10, 2007 10:33 am 
Timothy WallJul 10, 2007 11:10 am 
Maurice NaftalinJul 12, 2007 8:35 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] Fwd: Getting cursor position for Mac, Linux?Actions...
From:Maurice Naftalin (maur@googlemail.com)
Date:Jul 12, 2007 8:35:22 am
List:net.java.dev.jna.users

Thanks very much for that tip - I had overlooked MouseInfo completely. (MouseEvent.getLocationOnScreen is good, but only if you actually have a MouseEvent.) It just goes to show that you can't afford to ignore innovation - not even in a Java client API! On the other hand, I did learn about the nice ideas in JNA.

Maurice

On 10/07/07, Timothy Wall <twal@dev.java.net> wrote:

MouseInfo.getPointerInfo is available as of java 1.5, so if you can use that, you should.

Component.getLocationOnScreen requires you have a visible Java window in order to receive events, and it doesn't do much good if the mouse *isn't* in that window.

On Jul 10, 2007, at 1:21 PM, Daniel Kaufmann wrote:

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 Estoy utilizando la versión gratuita de SPAMfighter para usuarios privados. Ha eliminado 207 correos spam hasta la fecha. Los abonados no tienen este mensaje en sus correos. ¡Pruebe SPAMfighter gratis ya!