Fixes Issue #1535
As of Safari3, event.button returns 0 instead of 1. This change in the
API causes DOM.eventGetButton method to return -1. This change uses
event.which for Safari, Mozilla and Opera browsers and translates
the value to IE's more sensible set of event.button values.
Found by: fredsa, ronald.hughes
Patch by: jlabanca
Review by: knorton
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1772 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/impl/DOMImplMozilla.java b/user/src/com/google/gwt/user/client/impl/DOMImplMozilla.java
index 131d88b..4051d3f 100644
--- a/user/src/com/google/gwt/user/client/impl/DOMImplMozilla.java
+++ b/user/src/com/google/gwt/user/client/impl/DOMImplMozilla.java
@@ -37,19 +37,6 @@
}-*/;
@Override
- public native int eventGetButton(Event evt) /*-{
- // Mozilla and IE disagree on what the button codes for buttons should be.
- // Translating to match IE standard.
- var button = evt.button;
- if(button == 0) {
- return 1;
- } else if (button == 1) {
- return 4;
- }
- return button || -1;
- }-*/;
-
- @Override
public native int eventGetMouseWheelVelocityY(Event evt) /*-{
return evt.detail || -1;
}-*/;
diff --git a/user/src/com/google/gwt/user/client/impl/DOMImplOpera.java b/user/src/com/google/gwt/user/client/impl/DOMImplOpera.java
index 70ce86a..e34b4f3 100644
--- a/user/src/com/google/gwt/user/client/impl/DOMImplOpera.java
+++ b/user/src/com/google/gwt/user/client/impl/DOMImplOpera.java
@@ -24,18 +24,6 @@
public class DOMImplOpera extends DOMImplStandard {
@Override
- public native int eventGetButton(Event evt) /*-{
- // Opera and IE disagree on what the button codes for left button should be.
- // Translating to match IE standard.
- var button = evt.button;
- if(button == 0){
- return 1;
- } else {
- return button || -1;
- }
- }-*/;
-
- @Override
public native int eventGetMouseWheelVelocityY(Event evt) /*-{
return evt.detail * 4 || -1;
}-*/;
diff --git a/user/src/com/google/gwt/user/client/impl/DOMImplStandard.java b/user/src/com/google/gwt/user/client/impl/DOMImplStandard.java
index 276d2d5..0c642f1 100644
--- a/user/src/com/google/gwt/user/client/impl/DOMImplStandard.java
+++ b/user/src/com/google/gwt/user/client/impl/DOMImplStandard.java
@@ -39,6 +39,19 @@
}-*/;
@Override
+ public native int eventGetButton(Event evt) /*-{
+ // Standard browsers and IE disagree on what the button codes for buttons
+ // should be. Translating to match IE standard.
+ var button = evt.which;
+ if(button == 2) {
+ return 4;
+ } else if (button == 3) {
+ return 2;
+ }
+ return button || -1;
+ }-*/;
+
+ @Override
public native Element eventGetFromElement(Event evt) /*-{
// Standard browsers use relatedTarget rather than fromElement.
return evt.relatedTarget ? evt.relatedTarget : null;