Posted by
Andre on
Jan 02, 2024; 7:03pm
URL: https://forum.jogamp.org/Bug-after-Touch-tp4043236.html
iBug?
Hello. jogl 2.5.0 and java 12. win11, surface pro.
once i an while if i pinch, like zooming in with PointerType.Touch (important: use 2 fingers), the mouseMoved does not return and instead mouseDragged stays stuck when going back to PointerType.Mouse and fires constantly instead of mouseMoved.
Can anyone help?
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
import java.awt.Dimension;
import javax.swing.JFrame;
import com.jogamp.newt.awt.NewtCanvasAWT;
import com.jogamp.newt.event.MouseAdapter;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.util.FPSAnimator;
public class Test {
public static void main(String[] args) {
new Test();
}
private GLWindow glWindow;
private NewtCanvasAWT newtCanvasAWT;
private JFrame jFrame;
public Test() {
this.jFrame = new JFrame();
this.jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.jFrame.setMinimumSize(new Dimension(640, 480));
GLProfile profile = GLProfile.getDefault();
GLCapabilities glCapabilities = new GLCapabilities(profile);
this.glWindow = GLWindow.create(glCapabilities);
this.glWindow.addMouseListener(new MouseAdapter() {
@Override
public void mouseMoved(final MouseEvent e) {
System.out.println("move " + System.currentTimeMillis());
}
@Override
public void mouseDragged(final MouseEvent e) {
System.out.println("drag " + System.currentTimeMillis());
}
});
FPSAnimator a = new FPSAnimator(this.glWindow, 60, true);
this.newtCanvasAWT = new NewtCanvasAWT(this.glWindow);
this.jFrame.add(this.newtCanvasAWT);
this.jFrame.setVisible(true);
}
}

Happens like this too.
import com.jogamp.newt.event.MouseAdapter;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.util.FPSAnimator;
public class Test {
public static void main(String[] args) {
new Test();
}
private GLWindow glWindow;
public Test() {
GLProfile profile = GLProfile.getDefault();
GLCapabilities glCapabilities = new GLCapabilities(profile);
this.glWindow = GLWindow.create(glCapabilities);
this.glWindow.setSize(640, 480);
this.glWindow.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
System.out.print("Pressed " + System.currentTimeMillis());
System.out.print(" " + e.getPointerType(0) + " " + e.getPointerCount());
System.out.println();
}
@Override
public void mouseMoved(final MouseEvent e) {
System.out.print("Moved " + System.currentTimeMillis());
System.out.print(" " + e.getPointerType(0) + " " + e.getPointerCount());
System.out.println();
}
@Override
public void mouseDragged(final MouseEvent e) {
System.out.print("Dragged " + System.currentTimeMillis());
System.out.print(" " + e.getPointerType(0) + " " + e.getPointerCount());
System.out.println();
}
@Override
public void mouseReleased(final MouseEvent e) {
System.out.print("Released " + System.currentTimeMillis());
System.out.print(" " + e.getPointerType(0) + " " + e.getPointerCount());
System.out.println();
}
});
FPSAnimator a = new FPSAnimator(this.glWindow, 60, true);
a.start();
this.glWindow.setVisible(true);
}
}
if its ending on touch released the mouse somehow looses focus while touch still works.
So when moving the mouse gives no response. looks like "lost focus" but requestFocus() does not bring it back. see:

But if the chain of events ends with Mouse move it still works. i still wonder why mouse move shows up after touchrelease happens, But it works normally like this. See:

touching with 1 finger sometimes brings the responsiveness back.
i tried an earlier version. .... And 2.4.0 does the same here.
Jikes. i need that transition between Pointertype.Touch and. Mouse.
Since imouseMoved and mouseDragged are nearly the same event, i can quick fix it with checking if pressed and released is fired before and after drag by adding a Boolean.
I am a Robot