Mouse-Wheel Behavior

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()
                     );
                  }
               }
            }
         });

Thus spake bdgza:

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.


J.

With help to get started I wouldn’t mind giving it a go.

Thus spake bdgza:

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.

Can you do that?


J.

I’ll get on it and report back.

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:

Inventory
GridEditor
PolygonEditor
RegionGrid
CounterDetailViewer
GlobalMap
HidePiecesButton
HighlightLastMoved
KeyBufferer
LOS_Thread
MapCenterer
MenuDisplayer
PieceMover
SetupStack
StackExpander
Map
MultiRoll
PlayerHand
PrivateMap
TurnTracker
HtmlChart
PieceSlot
ServerAddressBook
ChatServerControls
RoomInteractionControlsInitializer
ChooseComponentDialog
ConfigureTree
ExtensionTree
ActionButton
DragBuffer
FreeRotator
ImagePicker
PieceDefiner
PropertySheet
TranslateWindow
ModuleManagerWindow
ADC2Module
ScrollPane
SplashScreen
AboutWindow

Keys:

WizardDisplayerImpl
GameModule
BasicCommandEncoder
BasicLogger
ChartWindow
Chatter
DiceButton
DoActionButton
TextItem
GlobalKeyCommand
GlobalOptions
Inventory
GridEditor
HexGridNumbering
PolygonEditor
RegionGrid
CounterDetailViewer
DeckGlobalKeyCommand
DrawPile
ForwardToChatter
ForwardToKeyBuffer
GlobalMap
HidePiecesButton
ImageSaver
KeyBufferer
LayerControl
LOS_Thread
MapShader
MassKeyCommand
MenuDisplayer
PieceMover
PieceRecenterer
Scroller
SetupStack
StackExpander
StackMetrics
TextSaver
Zoomer
Map
MultiRoll
NotesWindow
PieceWindow
PrivateMap
ChangePropertyButton
SpecialDiceButton
ToolbarMenu
TurnGlobalHotkey
TurnTracker
PieceSlot
PrivMsgCommand
SoundEncoder
ChatServerControls
VASSAL
SendSoundAction
RemovePiece
AutoConfigurer
BeanShellExpressionConfigurer
Configurer
ConfigureTree
HotKeyConfigurer
KeyModifiersConfigurer
KeyStrokeArrayConfigurer
NamedHotKeyConfigurer
NamedKeyStrokeArrayConfigurer
StringConfigurer
TextConfigurer
ActionButton
AreaOfEffect
BasicPiece
CalculatedProperty
Clone
CounterGlobalKeyCommand
Deck
Decorator
Delete
DynamicProperty
Embellishment
Footprint
FreeRotator
GamePiece
GlobalCommand
GlobalHotKey
Hideable
Immobilized
KeyBuffer
KeyCommand
KeyCommandSubMenu
KeySpecifier
Labeler
Marker
MovementMarkable
MultiImagePicker
NonRectangular
Obscurable
PieceDefiner
Pivot
PlaceMarker
PlaySound
Properties
PropertySheet
Replace
ReportState
RestrictCommands
Restricted
ReturnToDeck
SendToLocation
SetGlobalProperty
Stack
SubMenu
TableInfo
Translate
TriggerAction
UsePrototype
Localization
Resources
TranslatableAttribute
TranslateVassalWindow
TranslateWindow
VassalTranslation
BasicModule
EditorWindow
ModuleEditorWindow
Prefs
AbstractInterpreter
JavaNameConfigurer
HotkeySpecifier
ImageUtils
RenderingClues
SVGRenderer
org
AbstractOpImpl
ADC2Module
SymbolSet
KeyStrokeListener
KeyStrokeSource
LaunchButton
MacOSXMenuManager
MenuManager
NamedKeyManager
NamedKeyStroke
NamedKeyStrokeListener
Op
OpCache
SequenceEncoder

Hi!

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.

Thanks,

Martin

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.

That’s cool!

But does it bother others that the horizontal mouse-wheel scrolling is
backwards, with up equated to left instead of right? It drives me batty.

Pieter

-----Original Message-----
From: messages-bounces@vassalengine.org
[mailto:messages-bounces@vassalengine.org] On Behalf Of DrNostromo
Sent: Wednesday, February 02, 2011 10:41 AM
To: messages@vassalengine.org
Subject: [messages] [Feature Requests] Re: Mouse-Wheel Behavior

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.


Read this topic online here:
https://forum.vassalengine.org/t/mouse-wheel-behavior/3353/8

Thanks, that works on a Mac, too!

Requires a little extra “mousing” compared to the maximum comfort solution but is a big improvement already.

Cheers,

Martin

On the Mac, the Mighty Mouse ball can be scrolled left-right when hovering over the bar – and the map moves horizontally!

Nice.