Questions tagged [mouse-coordinates]

Mouse coordinates give the position of the mouse cursor on the display unit, and can be retrieved using the MouseEvent interface.

For browsers using JavaScript, there are three coordinates systems:

  • Screen: The coordinates of the mouse pointer in the global scope.
  • Client: The coordinates of the mouse pointer in the local DOM content scope.
  • Offset: The coordinates of the mouse pointer relative to the position of the padding edge of the target node.

The following code demonstrates the differences between the three:

<!DOCTYPE html>
<html>
<body onmousemove='showCoordinates(event);'>
<canvas width='200' height='200' style='border: 3px black solid'></canvas>
<br>Screen: <span id='scr'></span>
<br>Client: <span id='client'></span>
<br>Offset: <span id='offset'></span>
</body>
<script>
function showCoordinates(evt) {
scr.textContent=evt.screenX+', '+evt.screenY;
client.textContent=evt.clientX+', '+evt.clientY;
offset.textContent=evt.offsetX+', '+evt.offsetY;
}
</script>
</html>
73 questions
85
votes
10 answers

Mouse / Canvas X, Y to Three.js World X, Y, Z

I've searched around for an example that matches my use case but cannot find one. I'm trying to convert screen mouse co-ordinates into 3D world co-ordinates taking into account the camera. Solutions I've found all do ray intersection to achieve…
Rob Evans
  • 6,750
  • 4
  • 39
  • 56
80
votes
9 answers

How do I get the current mouse screen coordinates in WPF?

How to get current mouse coordination on the screen? I know only Mouse.GetPosition() which get mousePosition of element, but I want to get the coordination without using element.
Prince OfThief
  • 6,323
  • 14
  • 40
  • 53
44
votes
3 answers

How perform a drag (based in X,Y mouse coordinates) on Android using AccessibilityService?

I want know how to perform a drag on android based in X, Y mouse coordinates? consider as two simple examples, the Team Viewer/QuickSupport drawing the "password pattern" on remote smartphone and the Pen of Windows Paint respectively. All that i'm…
20
votes
2 answers

Get mouse position in scrollable div

Yet another question that has been pecking away at me the last few days. As you may have seen from my other questions I am creating some mind map software. So (extremely simplified) I have a two divs. One that is a square on the page, and another…
Adam Holmes
  • 1,783
  • 3
  • 20
  • 32
15
votes
1 answer

How can I get my own cursor coordinates in Firefox?

I'm currently designing a website and just realized it would help me a lot if I would know my own cursor coordinates. I mostly use Firefox for previewing the new page. So an add-on for Firefox would be great. I checked out Firebug, but didn't find…
Sandra
  • 765
  • 3
  • 10
  • 20
6
votes
2 answers

Tracking mouse coordinates in Qt

Let's say I have a widget in main window, and want to track mouse position ONLY on the widget: it means that left-low corner of widget must be local (0, 0). Q: How can I do this? p.s. NON of functions below do…
Mike
  • 563
  • 5
  • 15
  • 32
6
votes
1 answer

Translate mouse coordinates to a 3D plan

I'm building some kind of drag and drop app in javascript/jquery (DOM based, not canvas). The idea is to be able to drag divs on a 3D scene (a div rotated in 3D). It works on a 2D plan, the problem is when I rotate the scene in 3D, the objects…
Julian
  • 698
  • 2
  • 8
  • 17
4
votes
1 answer

DrawFocusRect with given aspect ratio in Delphi

I want to be able to draw a FocusRect on an image, which keeps the aspect ratio of the image. My problem is, that the FocusRect only depends on the y coordinates of the mouse. I just don't know how to let the rectangle depent on both mouse…
Henry
  • 43
  • 3
4
votes
3 answers

Absolute mouse positions on Processing

(This is a copy paste of a post I made on the Processing forum, where I haven't got an answer so far. I thought I might as well try here). Processing is a very cool way to draw stuff, specially for the webpages. Just as a reference…
fmsf
  • 36,317
  • 49
  • 147
  • 195
4
votes
1 answer

PYTHON- PYGAME: How do I know if a mouse clicked on an image?

I'm making a basic level game where if i click a card, a picture will show. The pictures are randomly chosen. and so far, I have assigned random pictures to a card and the cards are shown face down. So if i click the card, i want the assigned…
Maia F.
  • 41
  • 1
  • 1
  • 2
4
votes
1 answer

Yui Mouse Coordinates over Element

I'm trying to determine if the mouse is over an element preferably with YUI if there is a method for that already. Basically something like function bool IsMouseOver(Element);
CaffGeek
  • 21,856
  • 17
  • 100
  • 184
3
votes
0 answers

How send correctly mouse coordinates inside TImage component to Android Path.moveTo() and Path.lineTo() methods?

I found a android code that your goal is simulates an L-shaped drag path: 200 pixels right, then 200 pixels down. These values was predefined on code, how this could be achieved using the mouse coordinates of a TImage component and your events…
3
votes
1 answer

Getting mouse coordinates in firefox 41

I am trying to drag and drop a element based on mouse coordinates. Its working fine in chrome and IE but not working in firefox. Below is what I have tried: function createShape(event) { var stageContainer = $(".mainArea"); var stageOffset =…
kittu
  • 6,662
  • 21
  • 91
  • 185
3
votes
1 answer

Three.js - Getting the X, Y, and Z coordinates of mouse click

I'm using version 68 of three.js. I would like to click somewhere and get the X, Y, and Z coordinates. I followed the steps here, but they give me a Z value of 0: Mouse / Canvas X, Y to Three.js World X, Y, Z Basically, if I have a mesh in the…
Programmer_D
  • 601
  • 2
  • 15
  • 27
3
votes
1 answer

Mouse coordinates outside of a form

I'm trying to make a simple mouse macro program but i cannot figure out how to get the coordinates of the mouse outside of the form itself. I have tried with MousePosition and Cursor.Position but this only seems to take the coordinates inside the…
Vahx
  • 626
  • 10
  • 23
1
2 3 4 5