Login  Register

[Ardor3D] SwtMouseWrapper

Posted by Stefan on Aug 28, 2015; 8:45am
URL: https://forum.jogamp.org/Ardor3D-SwtMouseWrapper-tp4035151.html

Hi,

whenever I click an "exotic" mouse button I get following RuntimeException:

java.lang.RuntimeException: unknown button: 8
        at com.ardor3d.input.swt.SwtMouseWrapper.getButtonForEvent(SwtMouseWrapper.java:172)
        at com.ardor3d.input.swt.SwtMouseWrapper.mouseDown(SwtMouseWrapper.java:98)
        at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:192)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
        at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4481)
        ...

The Exception is caused by following method in the SwtMouseWrapper:

private MouseButton getButtonForEvent(final MouseEvent e) {
        MouseButton button;
        switch (e.button) { // ordering is different than swt
            case 1:
                button = MouseButton.LEFT;
                break;
            case 3:
                button = MouseButton.RIGHT;
                break;
            case 2:
                button = MouseButton.MIDDLE;
                break;
            default:
                throw new RuntimeException("unknown button: " + e.button);
        }
        return button;
    }

What is the recommended way to prevent this exception? Subclassing the SwtMouseWrapper?

Thanks for your help!

Regards,

Stefan