I am trying to disable movement of the globe on mouse click in World Wind. I expected to be able to do:
void disableGlobeDrag(WorldWindowGLCanvas ww) {
ww.addMouseMotionListener(new MyMouseMotionListener());
}
where MyMouseMotionListener consumes all of the mouse events. This is not working so instead I have to do:
void disableGlobeDrag(WorldWindowGLCanvas ww) {
for(MouseMotionListener l : ww.getMouseMotionListeners()) {
if(l.getClass().toString().equals("class gov.nasa.worldwind.awt.AWTInputHandler")) {
ww.removeMouseMotionListener(l);
}
}
}
Is it expected that consumed mouse events should still reach the gov.nasa.worldwind.awt.AWTInputHandler listener?
Update: WorldWindowGLCanvas is just calling addMouseMotionListener() on java.awt.Component so apparently I don't understand how consuming events works.
Update 2: despite sharing interfaces with Swing, calling WorldWindowGLCanvas.removeMouseMotionListener() with AWTInputHandler as the argument will prevent all other MouseMotionListeners from receiving events. The add and remove methods on AWTInputHandler should be used instead.