Questions tagged [mouseevent]

A general tag for user-interface events that are generated by the mouse. This includes pressing/releasing a button, clicking (including double/triple-clicks), moving, dragging, etc.

This tag deals with the events that are generated by preforming actions with a Computer Mouse and similar input devices which emulate the behaviour of a mouse (such as Touchpads and Graphic Tablets).

Mouse events are usually split into several categories:

  • Button Press (Button Down) event - The event where a previously unpressed mouse button just became pressed
  • Button Release (Button Release) event - The event where a previously pressed mouse button just became unpressed
  • Button Click event - A Button Press event followed by a Button Release event. In some platforms and locations, this concept has one or more of the following limitations:
    • The Press and Release both happend while the mouse was in the same place (the mouse wasn't moved between the press and the release). Sometimes there is a lighter version of this restriction, which only forces the mouse to be above the same "user interface element" on the press and release events.
    • The Press and Release both happend inside a limited (usually short) time interval.
  • Button Double (Triple/...) Click event - Two (Three/...) click events, one after another with the same mouse button. These may also have one or more of the limitations mentioned for a single click event
  • Button Move (Motion) event - An event where the mouse is moved. Usually this refers only to the case where none of the mouse buttons was pressed (for the case where one or more buttons was in fact pressed, see the next definition).
  • Button Drag event - An event where the mouse moves while one or more of the mouse buttons is held down
  • Button (Scroll) Wheel event - In modern mice, there is usually a wheel part called scroll-wheel, which can be moved (aka rolled, scrolled) up and down. Such a movement of that part is referred to as a Mouse Wheel event.
    • In some newer alternative input devices which also serve as a mouse, sometimes there won't be any physical whell. Instead, there may be hot-spot areas and/or buttons that will emulate the movement of the wheel. For example, in many touchpads, a movement in certain areas will be interpreted as scroll event.
    • Some mice (and other devices) allow scrolling not just up and down, but also in other directions (typically, left and right).

For more information and definitions, see the Computer Mouse and it's operation on Wikipedia.

6218 questions
2026
votes
17 answers

Click through div to underlying elements

I have a div that has background:transparent, along with border. Underneath this div, I have more elements. Currently, I'm able to click the underlying elements when I click outside of the overlay div. However, I'm unable to click the underlying…
Ryan
  • 21,437
  • 7
  • 25
  • 28
369
votes
15 answers

How to get the mouse position without events (without moving the mouse)?

Is it possible to get the mouse position with JavaScript after page loads without any mouse movement event (without moving the mouse)?
Norbert Tamas
  • 4,464
  • 5
  • 23
  • 28
288
votes
10 answers

change cursor to finger pointer

I have this a and I don't know that I need to insert into the "onmouseover" so that the cursor will change to finger pointer like a regular link: A I read somewhere that I…
Dvir Levy
  • 8,018
  • 11
  • 39
  • 60
276
votes
3 answers

JavaScript click handler not working as expected inside a for loop

I'm trying to learn JS and got an issue. I tried many things and googled but all in vain. Following piece of code doesn't work as expected. I should get value of i on click but it always returns 6. I'm pulling my hair out; please help. for (var i =…
JS-coder
  • 3,243
  • 2
  • 14
  • 14
174
votes
8 answers

jQuery get mouse position within an element

I was hoping to craft a control where a user could click inside a div, then drag the mouse, then let up on the mouse in order to indicate how long they want something to be. (This is for a calendar control, so the user will be indicating the…
Chris Dutrow
  • 48,402
  • 65
  • 188
  • 258
146
votes
14 answers

How do you Hover in ReactJS? - onMouseLeave not registered during fast hover over

How can you achieve either a hover event or active event in ReactJS when you do inline styling? I've found that the onMouseEnter, onMouseLeave approach is buggy, so hoping there is another way to do it. Specifically, if you mouse over a component…
126
votes
5 answers

How to simulate a click by using x,y coordinates in JavaScript?

Is it possible to use given coordinates in order to simulate a click in JavaScript within a webpage?
RadiantHex
  • 24,907
  • 47
  • 148
  • 244
125
votes
5 answers

When to choose mouseover() and hover() function?

What are the differences between jQuery .mouseover() and .hover() functions? If they are totally same why jQuery uses both?
Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231
96
votes
6 answers

Delay jquery hover event?

I would like to delay a hover event in jquery. I am reading from a file when user hovers over a link or label. I don't want this event to occur immediately in case the user is just moving the mouse across the screen. Is there a way to delay the…
Brettski
  • 19,351
  • 15
  • 74
  • 97
69
votes
3 answers

Simulating a mousedown, click, mouseup sequence in Tampermonkey?

I would like to simulate a whole click not just document.getElementsByClassName()[0].click(); How do I do that? Search results all seem to be about handling such events, not triggering them.
67
votes
2 answers

Detecting CGAssociateMouseAndMouseCursorPosition

We're making a user-space device driver for OS X that moves the cursor using Quartz Events, and we ran into a problem when games — especially ones that run in a windowed mode — can't properly capture the mouse pointer (= contain/keep it within the…
Dae
  • 2,345
  • 2
  • 22
  • 34
59
votes
2 answers

Is there a way to make controls transparent to mouse events in WPF?

Is there a way that I can let mouse events pass through to controls behind?
Jordan
  • 9,642
  • 10
  • 71
  • 141
58
votes
4 answers

identifying double click in java

I want to know how can we perform action when mouse is double clicked in a component.
Suraj Air
  • 2,063
  • 4
  • 22
  • 33
53
votes
1 answer

Weak performance of CGEventPost under GPU load

We've stumbled upon a performance problem with Quartz Events, more specifically CGEventPost: during heavy GPU load CGEventPost can block. We've created a small benchmark application to demonstrate the issue. This application is just a loop that…
Dae
  • 2,345
  • 2
  • 22
  • 34
52
votes
3 answers

Store mouse click event coordinates with matplotlib

I am trying to implement a simple mouse click event in matplotlib. I wish to plot a figure then use the mouse to select the lower and upper limits for integration. So far I am able to print the coordinates to screen but not store them for later use…
smashbro
  • 1,094
  • 1
  • 9
  • 19
1
2 3
99 100