Closed Bug 217560 Opened 21 years ago Closed 20 years ago

Left/Right clicks undiscriminated for double-clicks (ondblclick event)

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.8alpha1

People

(Reporter: jruderman, Assigned: emaijala+moz)

References

Details

Attachments

(2 files)

The following all trigger ondblclick:
Left Left
Left Right
Right Left
Right Right

Only the first should trigger ondblclick.

This is like bug 86468, except that it's not fixed.

I'm going to attach an HTML testcase, even though this mostly affects browser
chrome.
Attached file testcase
I just hit another manifestation of this bug, this time in Mozilla Firebird.  

1. Start with only one tab open.
2. Middle-click any link at the top of the viewport and near the middle.
  Result: a new background tab opens, and the tab bar appears. (good)
3. Quickly left-click on the new tab.
  Result: a third tab opens. (bad)
*** Bug 240658 has been marked as a duplicate of this bug. ***
Don't forget the middle mouse button, which adds:

Middle Left
Middle Right
Right Middle
Left Middle

(although autoscroll seems to block this in html and several other places.)

-[Unknown]
I run into this bug all the time in the Firefox download manager. When I first
select a downloaded file, then right click to pop up the context menu, it is
interpreted as a doubleclick and the file is being opened. Very frequently this
is an executable file. Fortunately the program pops up a warning dialog, but
still there is some danger of accidentally starting an executable to it if you
ask me.


~Grauw
Assignee: saari → firefox
Target Milestone: --- → mozilla1.8alpha1
*** Bug 244692 has been marked as a duplicate of this bug. ***
*** Bug 246279 has been marked as a duplicate of this bug. ***
Blocks: 211177
*** Bug 185259 has been marked as a duplicate of this bug. ***
*** Bug 211927 has been marked as a duplicate of this bug. ***
Taking..
Assignee: firefox → ere
Attached patch Patch v1Splinter Review
This is a patch to make the double-click work only if it's the same button
being clicked (plus some comment fixes). It does not prevent double-clicking
with the middle or right button (I suggest someone file another bug for that if
it's really necessary).
Actually, the right (or middle) double-click could be handled in bug 211177.
Attachment #152294 - Flags: review?(dean_tessman)
Comment on attachment 152294 [details] [diff] [review]
Patch v1

I agree with this approach.  We shouldn't be restricting which button can
trigger a double-click.  This means re-opening most of the bugs that were duped
against this one to properly check for, in mose cases, event.button == 0.

One question, is this what the other platforms do as well?
Attachment #152294 - Flags: review?(dean_tessman) → review+
Comment on attachment 152294 [details] [diff] [review]
Patch v1

I think that at least on GTK the toolkit provides support for triple-clicks, so
there is no need for additional code. I don't know about the others.
Attachment #152294 - Flags: superreview?(roc)
Yeah, I looked through the code and each platform handles clicks very
differently.  From the GTK2 code, it already works like this on that platform.
(In reply to comment #13)
> (From update of attachment 152294 [details] [diff] [review])
> I agree with this approach.  We shouldn't be restricting which button can
> trigger a double-click.  This means re-opening most of the bugs that were duped
> against this one to properly check for, in mose cases, event.button == 0.

If it isn't restricted here, there has to be a check for (event.button == 0)
EVERYWHERE the ondblclick event is used in Mozilla and Firefox UI.  That's
silly, unless you have a good reason that a double right-click should trigger
ondblclick.
(In reply to comment #16)
> If it isn't restricted here, there has to be a check for (event.button == 0)
> EVERYWHERE the ondblclick event is used in Mozilla and Firefox UI.  That's
> silly, unless you have a good reason that a double right-click should trigger
> ondblclick.

I couldn't find anything in the documentation on w3c.org that restricted
ondblclick to only left clicks.  As far as I can tell, it's open to come from
any mouse button, exactly as onclick is.  This is toolkit code.  The toolkit
shouldn't impose restrictions like this.

(I'm open to corrections if I'm wrong about the documentation.)
Even if we want to restrict ondblclick to the left button (actually, should that
be the "main" button or something to account for left-handed users?), it should
be done wherever the ondblclick event is fired (or thereabouts) and not in
nsWindow.cpp.
ondblclick does not appear in DOM 2 Events or in DOM 3 Events.  It only appears
in http://www.w3.org/TR/html401/interact/scripts.html#h-18.2.3, which doesn't
mention mouse buttons.

Internet Explorer only triggers ondblclick for double left-clicks.

I'd rather go with common sense and compatibility with Internet Explorer than a
strict reading of an old specification.

http://www.w3.org/TR/DOM-Level-3-Events/events.html includes an example that
suggests that they don't plan to add ondblclick, and that Internet Explorer is
wrong to skip onclick events for the second click of a double click.
Did you forget to include nsWindow.h or something like that in the patch? I
don't see a declaration for gLastMouseButton
It's in the third hunk among the other statics (they're all declared in
nsWindow.cpp).
Comment on attachment 152294 [details] [diff] [review]
Patch v1

oh oops! I think you should check this in while you continue discussing whether
to check for the left button.
Attachment #152294 - Flags: superreview?(roc) → superreview+
Comment on attachment 152294 [details] [diff] [review]
Patch v1

Requesting approval to check in this quite simple fix.
Attachment #152294 - Flags: approval1.8a2?
Comment on attachment 152294 [details] [diff] [review]
Patch v1

a=asa (on behalf of drivers) for checkin to 1.8a2
Attachment #152294 - Flags: approval1.8a2? → approval1.8a2+
Ok, the first patch is now checked in, so clicking two separate buttons doesn't
fire double-click events anymore. Now we should discuss if (and where) we want
to allow double-clicks for the first button only. Reportedly at least on gtk2
you can get double-clicks also with the right button, so I think now gtk2 and
win32 work in the same way.

To keep the platform parity I would keep windows/nsWindow.cpp as it is. Instead,
if double-clicks should be fired for only the main button, other buttons should
be filtered out somewhere around the place where the actual js event is fired.
How about a new bug for that, if it's deemed necessary?
No comments -> marking fixed.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
In the latest Firefox branch nightly (2004-07-28) I still see the behaviour I
described in comment #5... In other words, it doesn't work (everywhere)?

~Grauw
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: