How to define a mouseDown event.button before the event is trigerred | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to define a mouseDown event.button before the event is trigerred

I have this error and I just don't know how to get ride of it. I can add info if you want. Bellow error and code. ////////error Uncaught TypeError: Cannot read property 'button' of undefined at mouseDown (renderer.js:303) at index.html:196 ////////////code function mouseDown(e, imgs) { if (e.button == 0) {///some code}

12th Jun 2021, 11:22 AM
sylvain Bilhaud
sylvain Bilhaud - avatar
4 Answers
+ 1
What is the use of <imgs> argument of mouseDown function? I thought event handler functions supposedly take one argument only (the event)? not too sure though, Have you checked what <e> argument actually is in the console? How did you bind the event with the element?
12th Jun 2021, 1:52 PM
Ipang
+ 1
The event work perfectly in itself, and you can convey as much as you want info in it. And this is essential in electron. The clicked buttons works fine when they are clicked, but before then... there is this error.
13th Jun 2021, 12:24 AM
sylvain Bilhaud
sylvain Bilhaud - avatar
+ 1
I stopped to dev. Thanks for the help Tashi N san. I moved forwared.
18th Jun 2021, 12:12 PM
sylvain Bilhaud
sylvain Bilhaud - avatar
0
So the event is mapped fine, but error is still coming? that's odd. I'd suggest to either keep this thread open for further response, or delete it, and create a new thread with complete code attached, in a hope someone can help you out after reading the full version of the code. You can save the code in SoloLearn (as code bit) and share its link in thread Description following this guide https://www.sololearn.com/post/75089/?ref=app
13th Jun 2021, 5:52 AM
Ipang