Questions tagged [event-handling]

Event handling is a coding style about handling messages between a source and one or more subscribers. A point listener in the source provide a way which subscribed code can consume messages raised from the source.

12746 questions
71
votes
6 answers

Touch move getting stuck Ignored attempt to cancel a touchmove

I'm messing around with touch events on a touch slider and I keep getting the following error: Ignored attempt to cancel a touchmove event with cancelable=false, for example because scrolling is in progress and cannot be interrupted. I'm not…
souporserious
  • 2,079
  • 2
  • 27
  • 47
70
votes
6 answers

Listening to "esc" key event on div component in Vue.js

I wish to listen to an 'esc' key event in order to call a method in a Vue component. The docs shows this example: but i'm using a
, and need to catch the event from outside. However, I wish NOT to…
Chen
  • 2,958
  • 5
  • 26
  • 45
70
votes
4 answers

DOM event precedence

What order of precedence are events handled in JavaScript? Here are the events in alphabetical order... onabort - Loading of an image is interrupted onblur - An element loses focus onchange - The user changes the content of a field onclick - Mouse…
dacracot
  • 22,002
  • 26
  • 104
  • 152
70
votes
6 answers

How to decode character pressed from jQuery's keydown()'s event handler

I need to figure out which character was typed into a text field from within the handler that is called by jQuery's keydown function. key.which gives me only the keycode, but I need to figure out which ASCII character key represents. How do I do…
Chetan
  • 46,743
  • 31
  • 106
  • 145
69
votes
7 answers

Vanilla JavaScript version of jQuery .click

So maybe I'm just not looking in the right places but I can't find a good explanation of how to do the equivalent of jQuery's $('a').click(function(){ // code here }); in plain old JavaScript? Basically I want to run a function every time an a…
Duck in Custard
  • 1,043
  • 2
  • 10
  • 17
69
votes
7 answers

How to use onClick with divs in React.js

I'm making a very simple application where you can click on square divs to change their color from white to black. However, I'm having trouble. I'd like to use the onClick function to allow a user to click on a square to change its color, but it…
Leia_Organa
  • 1,894
  • 7
  • 28
  • 48
69
votes
9 answers

Android Overriding onBackPressed()

Is it possible to override onBackPressed() for only one activity ? On back button click I want to call a dialog on a specific Activity, but in all other activities i want it to work as it worked before (going to previous activities). EDITED Thank…
Jilberta
  • 2,836
  • 5
  • 30
  • 44
68
votes
10 answers

Best practice for defining button events in android

I have a Layout defined in XML which consists of several Buttons. Currently I am doing this in the OnCreate method to define the event handlers against the buttons: public void onCreate(Bundle savedInstanceState) { …
Haris Hasan
  • 29,856
  • 10
  • 92
  • 122
68
votes
2 answers

Is it bad to not unregister event handlers?

If I have an application with only a few event handlers registered (and the objects using the events are not disposed until the application is closed), do I really need to worry about unregistering those handlers? The only good reason I could see…
SwDevMan81
  • 48,814
  • 22
  • 151
  • 184
65
votes
4 answers

How do you handle oncut, oncopy, and onpaste in jQuery?

The jQuery documentation says the library has built-in support for the following events: blur, focus, load, resize, scroll, unload, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select, submit,…
Andrew Hedges
  • 21,688
  • 16
  • 67
  • 79
62
votes
11 answers

Fake "click" to activate an onclick method

I have an element with an onclick method. I would like to activate that method (or: fake a click on this element) within another function. Is this possible?
yoavf
  • 20,945
  • 9
  • 37
  • 38
60
votes
7 answers

Why people use message/event buses in their code?

I think that you have heard of message/event buses, it's the single place when all events in the system flow. Similar architectures are found in computer's motherboards and LAN networks. It's a good approach for motherboards and networks as it…
iirekm
  • 8,890
  • 5
  • 36
  • 46
60
votes
2 answers

Difference between ChildProcess close, exit events

When spawning child processes via spawn()/exec()/... in Node.js, there is a 'close' and an 'exit' event on child processes. What is the difference between those two and when do you need to use what?
Narigo
  • 2,979
  • 3
  • 20
  • 31
60
votes
5 answers

Detect focus initiated by tab key?

I want to detect the focus event of an element, but only if it was initiated by the user pressing the tab key. For example: If the user is focused on #foo and presses Tab, I want the…
HellaMad
  • 5,294
  • 6
  • 31
  • 53
58
votes
6 answers

How to click a browser button with JavaScript automatically?

How to click a button every second using JavaScript?
001
  • 62,807
  • 94
  • 230
  • 350