Bug Tracker

Modify

Ticket #4164 (closed bug: invalid)

Opened 4 years ago

Last modified 14 months ago

IE doesn't get an event.which property when fixing click events

Reported by: larholm Owned by: brandon
Priority: major Milestone: 1.3.2
Component: event Version: 1.3.1
Keywords: Cc:
Blocking: Blocked by:

Description

When you leftclick in IE any assigned click handlers will never have a "which" property on their event objects, despite having been through jQuery.event.fix().

The code in question is the following:

Add which for click: 1 == left; 2 == middle; 3 == right Note: button is not normalized, so don't use it if ( !event.which && event.button )

event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));

Since leftclicking sets the button property to 0 the above will never be triggered in IE, and IE will not get a which property on click events.

Change History

comment:1 Changed 4 years ago by dmethvin

So it sounds like the fix is something like:

   if ( !event.which && event.button!=undefined )

comment:2 Changed 4 years ago by jpsimons

Yeah surprising this bug is still around. event.which should be a reliable way to get the mouse button but it's currently returning "undefined" for the left mouse button.

comment:3 Changed 4 years ago by brandon

  • Status changed from new to closed
  • Resolution set to invalid

Unfortunately the event.button property is not set for click events. It is however set for mouseup/down/move ... but not click.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.