Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#12699 closed feature (invalid)

Implement event.which normalization inside .click() handler

Reported by: Ult Combo Owned by: Ult Combo
Priority: low Milestone: None
Component: event Version: 1.8.2
Keywords: ie7 ie7 ie8 Cc:
Blocked by: Blocking:


event.which already normalizes button presses for mousedown/mouseup events, is there any reason for it to not be implemented for the click event?

I thought jQuery would have normalized the event object for the click event as it does for the other mouse events, so I've coded it directly into my source without even looking at the documentation and just spent half of an hour pulling my hair because IE6-8 returns 0 for a left click inside the .click handler.

Test case

Is it possible to implement the button normalization for the .click() handler?

Change History (6)

comment:1 Changed 11 years ago by Ult Combo

Also IE9, Firefox, Chrome, Opera and Safari already return 1 for a left click.

Last edited 11 years ago by Ult Combo (previous) (diff)

comment:2 Changed 11 years ago by dmethvin

Component: unfiledevent
Keywords: ie7 ie7 ie8 added
Owner: set to Ult Combo
Priority: undecidedlow
Status: newpending

See #11741. The problem is that IE's event object doesn't set which properly. However, a click event only occurs on left click as far as I know, so it should not be required to inspect event.which to see what button was down. We could try to fake it and always set event.which to 1 but history has shown that tends to bite us in strange ways as well.

Is there a reason why you're checking event.which in a click handler?

comment:3 Changed 11 years ago by dmethvin

#12705 is a duplicate of this ticket.

comment:4 Changed 11 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

comment:5 Changed 11 years ago by Ult Combo

Woah, I almost completely forgot about this ticket.

The reason I was checking for event.which is simply that some browsers do fire the click event for the middle button (Chrome and Firefox) and even for the right button (Firefox) as shown in the ticket's test case.

So I just wanted to warrant that the user was pressing the left click. But I agree that might just be extra hackishness possibly not worth to be included in the core, checking for event.which <= 1 should suffice for my use case.

comment:6 Changed 10 years ago by JewelPengin

This is still an issue and seeing as the documentation clearly states that event.which is normalized, this should be a much higher priority IMHO.

Note: See TracTickets for help on using tickets.