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):
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()
);
}
}
}
});
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.
One reason I can think of for not doing this now is that at some point,
we’re going to switch to the standard navigation controls that you have
in various games and also in Google Maps:
drag = scroll
mousewheel = zoom
some keys = rotate
I have my doubts that changing this now, and then changing it again in
about a year is a good idea.
What I think would be a better solution would be to make all of the key
and mouse bindings user configurable in the preferences. That way, if
you want CTRL+wheel to zoom, you can, or if you want something else, you
can have that, too.
Is this something you’d be interested in working on? If so, I can show
you how to get started with the new Preferences code for 3.2.
With help to get started I wouldn’t mind giving it a go.
The first thing to do would be to locate all the places in the code where
we set hotkeys or mouse controls. Things to look for would be uses of the
KeyStroke and KeyEvent clases, MouseWheelEvent, and MouseWheelListener.
Possibly also these: MouseEvent, MouseListener, MouseMotionEvent,
MouseMotionListener. From that, make a list of what hotkeys and mouse
controls we already have.
I had a rough week and not much time to look into this again earlier.
When you say “where we set hotkeys or mouse controls” you mean user operation of controls, like toolbar, maps, boards, etc? Not every listener/adapter everywhere? You want me to list that SplashScreen adds a MouseAdapter to listen for a mouseReleased event?
Remember that I am not very familiar with the VASSAL code.
Cleaned up list of references to Mouse controls:
…
I tried to make a similar list of cleaned up Key references, but this turns out to be difficult. “Key” is used in more ways than keyboard keys, Keys as in IDs:
…
The full lists didn’t fit in the post, so I will post just the filenames. Mouse:
Further on mouse-wheel behaviour: Is there a way to scroll horizontally on a Mac? I tried combining CTRL, SHIFT, ALT and COMMAND with the mouse wheel, but nothing produces horizontal scrolling.
Ideally, of course, the horizontal scrolling on the Mighty Mouse would produce horizontal scrolling in VASSAL.
Any suggestions on what I can do already are most welcome.
Otherwise, please add to the list of request for future features.
I don’t know about a Mac but on a PC, if you hold the mouse pointer over the horizontal scroll bar at the bottom of the map, the wheel will then scroll the map horizontally.
I don’t know about a Mac but on a PC, if you hold the mouse pointer over
the horizontal scroll bar at the bottom of the map, the wheel will then
scroll the map horizontally.