How mouseX and MouseY give coordinates?

edited May 2014 in General Discussion

Just wonder that mouseX and mouseY return us the current coordinates of mouse along X and Y axis, but does any one know how or which algorithm they used to calculate the X and Y coordinates?? I need detail functionality of it.
?? can any one help me out

Answers

  • Answer ✓

    I have moved this topic to this section. In future please read the guidelines when choosing a category.

    I need detail functionality of it.

    Why do you need it? If we knew then you might get a more appropriate answer than this one.

    When the mouse is used this is detected by the operating system and it generates an event-object, in this case a mouse-event-object. Inside this object are the screen coordinates of the mouse pointer (top-left of the screen is x=0, y=0).

    The event-object is stored on an event-queue, the currently active application removes event-objects from the event-queue and if it is a mouse event it calculates the position of the mouse pointer relative to the top-left corner of the client area. If the current application is Processing then the relative mouse position is stored in mouseX and mouseY ready for the user to work with.

  • @quark: thank you very much for your quick response. I will definitely from next own words will consider the guideline.

    Actually why I need is I am writing some sort of application in which mouse coordinates need to be mapped on the OpenCV libraries to check the exact location of object on the screen. so I was wonder how and which hidden functionality is being implemented to mapped the coordinates. on can you refer some sort of research paper where I can get this detail functionality. thank you

  • Under the hood it's a basic Java MouseListener and MouseMotionListener. The Processing code is freely available, so if you're very curious, you should be poking through it here: https://github.com/processing/processing

Sign In or Register to comment.