Questions tagged [mouse-position]

197 questions
742
votes
8 answers

What is the difference between screenX/Y, clientX/Y and pageX/Y?

What is the difference between screenX/Y, clientX/Y and pageX/Y? Also for iPad Safari, are the calculations similar as on desktop—OR there is some difference because of viewport? It would be great if you could point me to an example.
hmthr
  • 7,711
  • 5
  • 19
  • 13
162
votes
5 answers

Real mouse position in canvas

I'm trying to draw with the mouse over a HTML5 canvas, but the only way that it seems to work well is if the canvas is in the position 0,0 (upper left corner) if I change the canvas position, for some reason it doesn't draw like it should. Here is…
Solar Confinement
  • 2,153
  • 3
  • 21
  • 28
139
votes
10 answers

Getting mouse position in c#

How do I get the mouse position? I want it in term of screen position. I start my program I want to set to the current mouse position. Location.X = ?? Location.Y = ?? Edit: This must happen before the form is created.
Athiwat Chunlakhan
  • 7,589
  • 14
  • 44
  • 72
41
votes
11 answers

Get cursor position with respect to the control - C#

I want to get the mouse position with respect to the control in which mouse pointer is present. That means when I place the cursor to the starting point (Top-Left corner) of control it should give (0,0). I am using the following code: private…
Farid-ur-Rahman
  • 1,809
  • 9
  • 31
  • 47
39
votes
4 answers

Mouse Position Python Tkinter

Is there a way to get the position of the mouse and set it as a var?
Kyle Pfromer
  • 1,485
  • 1
  • 15
  • 26
36
votes
6 answers

jQuery Set Mouse Position (not cursor position)

I have a link that, when clicked, I would like it to move the position of the mouse to the right (or anywhere within the viewport, for that matter). in code it would probably look similar to the following: $('a#expand').click(function(e){ …
Michael
  • 1,786
  • 5
  • 23
  • 42
33
votes
7 answers

Why is event.clientX incorrectly showing as 0 in firefox for dragend event?

The alert from dragend is showing mouseX as zero no matter where it is currently. This works fine in Chrome so not sure what I'm doing wrong. function move(e,obj,but){ if(typeof(obj) === 'string'){ obj = document.getElementById(obj) ; …
Magic Lasso
  • 1,504
  • 5
  • 22
  • 29
22
votes
3 answers

Get Mouse Position on Canvas (But NOT on window)?

I have a project in WPF 4 and vb.net 2010. I have a canvas inside a window. The window is full screen, but the canvas is set to a solid 640x480 in the center of the window. I need to get the mouse position inside of the canvas, but NOT inside of the…
CodeMouse92
  • 6,840
  • 14
  • 73
  • 130
19
votes
4 answers

Javascript: Get mouse position relative to parent element

Is there any way to get mouse position relative to it's parent element? Let's say I have a structure:
When I bring my mouse over span element I need to get its position relative to its parent…
Peterim
  • 1,029
  • 4
  • 16
  • 25
18
votes
4 answers

How to get mouse position on screen in WPF?

It works within a specific control, but it doesn't work out the specific control. How to get mouse position and use mouse events independently of any control just directly from screen (without Platform Invoke)? 2 needed points: Mouse events when…
Ziya Ceferov
  • 305
  • 1
  • 3
  • 7
15
votes
4 answers

How do I set the position of the mouse cursor from a Console app in C#?

I've found many articles on how to set the mouse position in a C# windows forms project - I want to do this in a console application. How can I set the absolute mouse position from a C# windows console application? Thanks! Hint: it's not…
14
votes
3 answers

Ignoring child elements on mousemove

I try to get mouse position relative to an element using mousemove. It works fine, but when the mouse hover a child element, the coordinates are relative to this child. I want the mouse position relative to the parent div, not the child. See this…
Julian
  • 698
  • 2
  • 8
  • 17
13
votes
2 answers

Mouse position on mouseover event

Is it possible to get the exact mouse position in a mouseouver event of an image? If I use a function that updates the mouse position on a document mouse move event, I can have problems with delay and this kind of thing and wouldn't get the EXACT…
user2013107
  • 265
  • 1
  • 4
  • 12
13
votes
2 answers

Open popup at clicked position

Hi, I have done a popup which is by default hidden and opened whenever a click is triggered on window. Popup must be shown at wherever the event is triggered.But there are some constraints: Popup must be shown at current visible…
Rama Rao M
  • 2,961
  • 11
  • 44
  • 64
12
votes
2 answers

How to check if webpage page is scrolled?

Is there any way in javascript to check if web page has been vertically scrolled? specially for Internet Explorer? I need to get the mouse position in IE but using jQuery event e.pageY it gives correct value when page is not scrolled but when page…
Muzzammil Hussain
  • 133
  • 1
  • 1
  • 4
1
2 3
13 14