Nifty - scrollpanel movement in android

Hi all,

I’ve noticed that in android there’s no confortable way to move a nftygui scroll panel, just by directly touching the arrows while in desktop you can use the mouse wheel over the scroll or dragging the scroll bar.

Checking jme code I found that in com.jme3.niftygui.InputSystemJme method onTouchEventQueued (the one forwarding touch events to nifty it’s only using TouchEvent.Type DOWN and UP, ignoring all other events like MOVE, SCROLL, HOVER_MOVE…:

......
        switch (evt.getType()) {
            case DOWN:
                if (inputPointerId != -1) {
                    // Another touch was done by the user
                    // while the other interacts with nifty, ignore.
                    break;
                }
                
                inputPointerId = evt.getPointerId();
                handleMouseEvent(0, true, nic, evt);
                
                break;
            case UP:
                if (inputPointerId != evt.getPointerId()) {
                    // Another touch was done by the user
                    // while the other interacts with nifty, ignore.
                    break;
                }
                
                inputPointerId = -1;
                handleMouseEvent(0, false, nic, evt);
                
                break;
......

So there’s no gesture converted in nifty into a mouse wheel event or any other allowing a better scrollpanel movement. I added the following case to onTouchEventQueued to translate SCROLL into mouse wheel:

......
            case SCROLL:
                // process scroll as wheel event should make scroll panels somehow work
                nic.processMouseEvent(x, y, (int)evt.getDeltaY(), -1, false);

                break;
......

And this way I was able to move the scroll panel dragging over scroll bar :partying_face: but not over the content because it was processed as a click event over them so although better, it’s still not the desired behaviour.

In adition to that, this only applies to vertical scrolls (I’m using deltaY) but a horizontal scroll bar would react to this also (all scrolls react to mouse wheel).

I’m trying to figure out how to make it better but I’m not sure how. Any ideas?

Thanks

1 Like