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
25
votes
10 answers

Trigger 'dummy' mouse wheel event

Is there a way to trigger a scroll wheel event with an arbitrary delta. Just like jQuery does with 'click' like: $('#selector').trigger('click'); I need something like that just with an scrollwheel…
escusado
  • 445
  • 2
  • 5
  • 10
25
votes
3 answers

Which mouse button is the middle one?

I'm currently developing a program in Java where a certain event must be triggered only when the user clicks with both the left and the right click on a button. Since it is a little unconventional, I decided to first test this. Here it is: import…
Radu Murzea
  • 10,724
  • 10
  • 47
  • 69
25
votes
6 answers

Mouseleave triggered by click

I have an absolutely-positioned div, and I'm trying to keep track of when the mouse moves over it, and when the mouse leaves. Unfortunately clicking on the text in the box occasionally triggers the mouseleave event. DEMO: js fiddle How can I…
Adam Rackis
  • 82,527
  • 56
  • 270
  • 393
25
votes
4 answers

How to simulate mouse click from Mac App to other Application

I am trying to simulate mouse click on iphone simulator from macos App for that I am using CGEvents . the process id is 33554 for iPhone simulator let point = CGPoint(x: 500 , y:300) let eventMouseDown = CGEvent(mouseEventSource: nil, mouseType:…
Faisal Khalid
  • 620
  • 10
  • 22
25
votes
3 answers

ActionListener on JLabel or JTable cell

I have a JTable with JLabel[][] as data. Now I want to detect a double click on either the JLabel or a table cell (but only in one of the columns). How can I add an Action/MouseListener on JLabel respectively table cell?
stefita
  • 1,785
  • 2
  • 20
  • 35
24
votes
6 answers

Is there a way to trigger mousemove and get event.pageX, event.pageY?

So, like the question specifies, is there a way to trigger a mousemove event in jQuery which also sends the mouse coordinates to the event Object? So far my code can trigger the mousemove using the .trigger(event) function but the event.pageX and…
Geo P
  • 754
  • 1
  • 5
  • 18
24
votes
3 answers

Why can't a mouseup event prevent a click event

jsfiddle
function h(e) { e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); alert(e.type); return…
beatgammit
  • 19,817
  • 19
  • 86
  • 129
23
votes
2 answers

How can I simulate mouse events from code?

I would like to simulate mouse events using the Win32 API; how can I do it? What I want to do is simulate the event at the most basic level, the level at which the system has just the event type and the co-ordinates and hasn't yet figured which…
Dharma
  • 231
  • 1
  • 2
  • 3
23
votes
3 answers

Smooth vertical scrolling on mouse wheel in vanilla javascript?

I am a huge fan for vanilla javascript, currently I am working on a project where I need to implement smooth scrolling on mouse wheel scroll. I want to implement this using vanilla JS. I found a jQuery snippet on doing some research which go like…
Adeel Imran
  • 13,166
  • 8
  • 62
  • 77
23
votes
6 answers

How can I attach custom behaviour to a double click in jsTree?

I'm using the jsTree jQuery plugin and want to execute code when the user double clicks a node. I can't seem to get it to work. I found some documentation on a ondblclk event but it doesn't fire. browser.jstree( { …
John Mills
  • 10,020
  • 12
  • 74
  • 121
23
votes
9 answers

Why is the TreeViewItem's MouseDoubleClick event being raised multiple times per double click?

XAML