Class KeyBufferer

java.lang.Object
java.awt.event.MouseAdapter
VASSAL.build.module.map.KeyBufferer
All Implemented Interfaces:
MouseListener, MouseMotionListener, MouseWheelListener, EventListener, Buildable, Drawable

public class KeyBufferer extends MouseAdapter implements Buildable, MouseMotionListener, Drawable
Selects and unselects pieces on the map, using the mouse.

The KeyBufferer listens for mouse clicks and drags on its parent Map, determines whether the user is performing a "lasso"/"band-select" or just clicking, draws the selection rectangle where appropriate, and at the end of each relevant mouse action updates the KeyBuffer to maintain the list of which pieces are currently "Selected" in the UI for the parent map.

Its rather misleading name derives from the fact that the selected units are kept in a KeyBuffer, with the idea being that if the player now presses a key, any resulting key command would be applied to all the selected pieces, even though the actual tracking of keys getting pressed and key commands getting applied all happens elsewhere, i.e. in the KeyBuffer class). A more appropriate name might have been e.g. "MouseSelection".

If the user clicks on a GamePiece, that piece is added to the KeyBuffer. draw(Graphics, Map) is responsible for drawing the mouse selection rectangle, and mouseDragged(MouseEvent) is responsible for triggering repaint events as the selection rectangle is moved.

If you are looking for the drag-and-drop handler for dragging pieces on or between maps, instead see PieceMover.

See Also: