Posted by
ag123 on
Aug 22, 2022; 7:24pm
URL: https://forum.jogamp.org/Java3D-bug-using-JDK11-tp4039952p4041824.html
hi all,
what i experienced is the lost of the right button for panning (translating) the view.
I attempted a fix.
this is done in
org.jogamp.java3d.utils.behaviors.vp.OrbitBehavior.java
https://jogamp.org/cgit/java3d/java3d-utils.git/tree/src/main/java/org/jogamp/java3d/utils/behaviors/vp/OrbitBehavior.java#n884the code is made to read this way:
boolean rotate(MouseEvent evt) {
if (rotateEnabled) {
if ((leftButton == ROTATE) && SwingUtilities.isLeftMouseButton(evt) &&
(!evt.isAltDown() && !evt.isMetaDown())) {
return true;
}
if ((middleButton == ROTATE) && SwingUtilities.isMiddleMouseButton(evt) &&
(evt.isAltDown() && !evt.isMetaDown())) {
return true;
}
if ((rightButton == ROTATE) && SwingUtilities.isRightMouseButton(evt) &&
(!evt.isAltDown() && evt.isMetaDown())) {
return true;
}
}
return false;
}
boolean zoom(MouseEvent evt) {
if (zoomEnabled) {
if (evt instanceof java.awt.event.MouseWheelEvent) {
return true;
}
if ((leftButton == ZOOM) && SwingUtilities.isLeftMouseButton(evt) &&
(!evt.isAltDown() && !evt.isMetaDown())) {
return true;
}
if ((middleButton == ZOOM) && SwingUtilities.isMiddleMouseButton(evt) &&
(evt.isAltDown() && !evt.isMetaDown())) {
return true;
}
if ((rightButton == ZOOM) && SwingUtilities.isRightMouseButton(evt) &&
!evt.isAltDown() && evt.isMetaDown()) {
return true;
}
}
return false;
}
boolean translate(MouseEvent evt) {
if (translateEnabled) {
if ((leftButton == TRANSLATE) && SwingUtilities.isLeftMouseButton(evt) &&
(!evt.isAltDown() && !evt.isMetaDown())) {
return true;
}
if ((middleButton == TRANSLATE) && SwingUtilities.isMiddleMouseButton(evt) &&
(evt.isAltDown() && !evt.isMetaDown())) {
return true;
}
if (rightButton == TRANSLATE && SwingUtilities.isRightMouseButton(evt) &&
!evt.isAltDown() && !evt.isMetaDown()) {
return true;
}
}
return false;
}
by adding SwingUtilities.is{ Left , Middle, Right }MouseButton(evt) in the if clauses for the respective button checks.
this apparently solved for problem for AdoptJDK11 running in Linux. I've not tested in any other platforms.
This is for a "3 button mouse" i.e. left and right buttons, and the mousewheel is the middle button.
The mousewheel codes is untouched. physically, I rotate the mouse wheel for zooming.
I tweaked the if statement in the last translate() clause
if (rightButton == TRANSLATE && SwingUtilities.isRightMouseButton(evt) &&
!evt.isAltDown() && !evt.isMetaDown()) {
return true;
}
the original is somewhat different, in this case, I'm checking for a right mouse click/drag with no modifiers, i.e. no Alt and no Meta. I'm not sure how 'other' platforms and different mouses would respond as this is specific to the '3 button' (left, wheel, right) mouse.
I did not actually change the original codes, rather i copied the class and renamed it, then make the changes.
I'd guess it would be similar by inheriting and overriding the 3 methods.
This would likely help if you are using OrbitBehavior.
when I debugged the codes, it turns out that without adding the specific SwingUtilities.is{Left,Middle,Right}MouseButton(evt) && clauses, the codes terminate in the rotate() method and is not processed for translate. hence, my 'right mouse' drag is not processed, i lost 'panning' functionality. The above fix restored my 'preferred' behavior with a working translate on right mouse drag.
thanks ot @goodwilling for some pointers.
edit:
i'm suspecting that based on the conversations above, the button responses and order of the buttons could be different between mouses.
this is probably influenced by specific mouse drivers.