[messages] [Feature Requests] Mouse-Wheel Behavior

bdgza bdegroot at gmail.com
Tue Oct 12 04:34:34 MST 2010


I probably posted in the wrong forum, I'll try here.

I have written some custom sub-classes for my module to change the
mouse-wheel behavior. I understand the default VASSAL is:
mouse-wheel = scrolling vertical
CTRL+mouse-wheel = scrolling horizontal

I changed it for my module to:
mouse-wheel = scrolling vertical
SHIFT+mouse-wheel = scrolling horizontal (the default MacOS X method)
CTRL+mouse-wheel = zoom in/out

Is there any reason why this should not be the standard VASSAL way of
using the mouse-wheel in all modules? Implementing this as standard (at
least in the MacOS X) version will allow my 2-axis scroll-wheel to
scroll horizontal as Logitech picks up the SHIFT+mouse-wheel
automatically. I never even knew about the CTRL+mouse-wheel for
horizontal scrolling until I looked into making these sub-classes, I
simply thought horizontal scrolling in VASSAL was broken.

---
from my sub-class of AdjustableSpeedScrollPane (parentMap is set in the
constructor):


Code:

viewport.addMouseWheelListener(new MouseWheelListener() {
            public void mouseWheelMoved(MouseWheelEvent e) {
               if (e.getScrollAmount() == 0) return;
               
               Zoomer mapZoomer = null; 
                  
               if (parentMap != null)
                  mapZoomer =  parentMap.getZoomer();
               
               if (e.getScrollType() ==
MouseWheelEvent.WHEEL_UNIT_SCROLL) {
                  if ((mapZoomer != null) && (e.isControlDown())) {
                     // zoom
                     int notches = e.getWheelRotation();
                     int amount = e.getScrollAmount();

                     for (int i = 0; i < amount; i++) {
                        if (e.getScrollType() ==
MouseWheelEvent.WHEEL_UNIT_SCROLL) {
                           if (notches < 0) {
                              //UP
                              mapZoomer.zoomIn();
                           } else {
                              //DOWN
                              mapZoomer.zoomOut();
                           }
                        }
                     }

                  } else {
                     JScrollBar bar = e.isShiftDown() ?
                           horizontalScrollBar :
                              verticalScrollBar;
                     if (bar == null || !bar.isVisible()) return;

                     bar.setValue(
                           bar.getValue() +
                           e.getUnitsToScroll() *
                           bar.getUnitIncrement()
                     );
                  }
               }
            }
         });




_______________________________________________
Read this topic online here:
http://www.vassalengine.org/forum/viewtopic.php?p=20229#p20229


More information about the messages mailing list