Closed GoogleCodeExporter closed 9 years ago
Interesting!
What hardware are you using specifically? Do AWT and Swing apps have the
correct behaviour, or is this just a limitation of the Swing --> Piccolo2D
mouse event conversion process?
Original comment by heue...@gmail.com
on 7 Feb 2011 at 5:07
Good point, actually horizontal scrolling does not work with AWT and Swing
apps, but it does work in Eclipse. However, other applications do not throw an
exception. Horizontal scrolling results in a MouseEvent with getButton()
returning MouseEvent.NOBUTTON causing the Piccolo2D conversion process to throw
the exception. Maybe this is a Java Swing issue...
Original comment by nls...@gmail.com
on 7 Feb 2011 at 6:24
I would assert Piccolo2D shouldn't throw an exception if getButton() returns
MouseEvent.NOBUTTON then. There may be some confusion between
MouseEvent.MOUSE_DRAGGED and MouseEvent.MOUSE_MOVED though, see e.g.
PCanvas.java, lines 729-734 and 744-749.
Original comment by heue...@gmail.com
on 1 Nov 2011 at 7:34
Line 761 creates the button value based on the raw event's getModifiers() (see
call to copyButtonsFromModifiers).
For the device you are talking about, does event.getModifiers() or
event.getModifiersEx() give any indication of a special button press? Maybe
there is a natural translation from that to some state we can track...
Original comment by atdi...@gmail.com
on 2 Nov 2011 at 1:39
Unfortunately, the event does store much information in this case since
horizontal scroll wheel support seems not to be implemented in AWT/Swing. I
have found this related feature request:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6440198
Currently on my system two events are generated with the following properties:
java.awt.event.MouseEvent[MOUSE_PRESSED,(320,295),absolute(425,421),button=0,cli
ckCount=1]
java.awt.event.MouseEvent[MOUSE_RELEASED,(320,295),absolute(425,421),button=0,cl
ickCount=1]
The methods getModifiers() and getModifiersEx() return 0 for these events. Both
events cause an exception, I have only reported the fist one above.
Original comment by nls...@gmail.com
on 2 Nov 2011 at 8:40
[deleted comment]
Actually it is not even possible to distinguish right from left scrolling with
the events fired by Sun Java 6. I have also tested this with OpenJDK Java 6/7
with the following results for right tilt followed by left tilt:
Sun Java 6:
java.awt.event.MouseEvent[MOUSE_PRESSED,(385,400),absolute(549,601),button=0,cli
ckCount=1]
java.awt.event.MouseEvent[MOUSE_RELEASED,(385,400),absolute(549,601),button=0,cl
ickCount=1]
java.awt.event.MouseEvent[MOUSE_PRESSED,(387,400),absolute(551,601),button=0,cli
ckCount=1]
java.awt.event.MouseEvent[MOUSE_RELEASED,(387,400),absolute(551,601),button=0,cl
ickCount=1]
OpenJDK Java 6:
java.awt.event.MouseEvent[MOUSE_PRESSED,(245,274),absolute(350,400),button=0,cli
ckCount=1]
java.awt.event.MouseEvent[MOUSE_RELEASED,(245,274),absolute(350,400),button=0,cl
ickCount=1]
java.awt.event.MouseEvent[MOUSE_PRESSED,(311,274),absolute(416,400),button=0,cli
ckCount=1]
java.awt.event.MouseEvent[MOUSE_RELEASED,(311,274),absolute(416,400),button=0,cl
ickCount=1]
OpenJDK Java 7:
java.awt.event.MouseEvent[MOUSE_PRESSED,(261,202),absolute(366,328),button=5,ext
Modifiers=Button5,clickCount=1]
java.awt.event.MouseEvent[MOUSE_RELEASED,(261,202),absolute(366,328),button=5,cl
ickCount=1]
java.awt.event.MouseEvent[MOUSE_PRESSED,(261,202),absolute(366,328),button=4,ext
Modifiers=Button4,clickCount=1]
java.awt.event.MouseEvent[MOUSE_RELEASED,(261,202),absolute(366,328),button=4,cl
ickCount=1]
With Java 7 it might be possible to implement a workaround since button 4 and 5
are used to indicate left and right scrolling, but this might be system
dependent.
I would suggest just to ignore these events for now instead of throwing an
exception until Java officially supports horizontal scrolling.
Original comment by nls...@gmail.com
on 3 Nov 2011 at 9:26
+1 to ignoring these events for now instead of throwing an exception for the
release-1.3 branch.
A comment in the Sun bug above describes a workaround for OSX
"Apple have added a workaround for this in Radar #4631846 - horizontal
scrolling creates a MouseWheelEvent with the "Shift" modifier set. This is a
much lower impact method than that specified above and works quite well. Any
chance it could be extended across platform?"
For svn trunk I think Piccolo2D should forward on events to the best of its
ability, and add support to e.g. PInputEvent for these platform-specific
workarounds, in case clients wish to implement horizontal scrolling on their
own.
Original comment by heue...@gmail.com
on 3 Nov 2011 at 9:48
I ran into this unexpectedly on linux with a mouse that had buttons 4-5
mismapped as 6-7 when testing issue 236.
I also wanted to forward this note I received from an AWT engineer:
"[H]orizontal scrolling is indeed a problem in AWT/Swing. We don't have public
API for that (but we do for vertical/wheel events). It can be introduced in
JDK8, but given the current status of AWT and Swing, I don't think it makes
much sense.
However, some of the Swing controls (e.g. JScrollPane) support horizontal
scrolling emulation. When mouse wheel is rotated with Shift being pressed,
horizontal scrolling takes place. In Mac OS X Port, we translated native
horizontal events (e.g. from MacBook/Pro touchpad) into Shift+MouseWheel, so it
should also work."
Original comment by heue...@gmail.com
on 23 Feb 2012 at 10:11
Fixed on branches/release-1.3.1
$ svn commit -m "Issue 207 ; ignore mouse pressed and released events with
button MouseEvent.NOBUTTON instead of throwing an exception" .
Committed revision 1174.
and svn trunk
$ svn commit -m "Issue 207 ; ignore mouse pressed and released events with
button MouseEvent.NOBUTTON instead of throwing an exception" .
Committed revision 1175.
Will create a new issue for button 4/5 support + horizontal scrolling emulation.
Original comment by heue...@gmail.com
on 31 Aug 2012 at 8:12
See related issue 241
Original comment by heue...@gmail.com
on 31 Aug 2012 at 8:16
Original comment by heue...@gmail.com
on 26 Nov 2013 at 5:42
Original issue reported on code.google.com by
nls...@gmail.com
on 7 Feb 2011 at 3:42