sdljava.event
Class MouseButtonState

java.lang.Object
  extended by sdljava.event.MouseButtonState

public class MouseButtonState
extends java.lang.Object

The current state of the mouse buttons.

Version:
$Id: MouseButtonState.java,v 1.4 2005/01/19 03:09:12 ivan_ganza Exp $

Field Summary
(package private)  int buttons
          Current button state values (possibly ORed together)
(package private) static java.util.Map buttonStateCache
          cache of MouseButtonState instances, one for each possible mods values
static int SDL_BUTTON_LEFT
           
static int SDL_BUTTON_MIDDLE
           
static int SDL_BUTTON_RIGHT
           
static int SDL_BUTTON_WHEELDOWN
           
static int SDL_BUTTON_WHEELUP
           
 
Constructor Summary
protected MouseButtonState(int buttons)
          Creates a new MouseButtonState instance.
 
Method Summary
(package private)  int button(int x)
           
 boolean buttonLeft()
          Get if the left mouse button is pressed
 boolean buttonMiddle()
          Get if the middle mouse button is pressed
 boolean buttonRight()
          Get if the right mouse button is pressed
static MouseButtonState get(int buttons)
          Get the MouseButtonState instance identified by mods.
 int getState()
           
 java.lang.String toString()
          Return a string represenation of this object
 boolean wheelDown()
          Get if the wheel is down
 boolean wheelUp()
          Get if the wheel is up
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SDL_BUTTON_LEFT

public static final int SDL_BUTTON_LEFT
See Also:
Constant Field Values

SDL_BUTTON_MIDDLE

public static final int SDL_BUTTON_MIDDLE
See Also:
Constant Field Values

SDL_BUTTON_RIGHT

public static final int SDL_BUTTON_RIGHT
See Also:
Constant Field Values

SDL_BUTTON_WHEELUP

public static final int SDL_BUTTON_WHEELUP
See Also:
Constant Field Values

SDL_BUTTON_WHEELDOWN

public static final int SDL_BUTTON_WHEELDOWN
See Also:
Constant Field Values

buttonStateCache

static java.util.Map buttonStateCache
cache of MouseButtonState instances, one for each possible mods values


buttons

int buttons
Current button state values (possibly ORed together)

Constructor Detail

MouseButtonState

protected MouseButtonState(int buttons)
Creates a new MouseButtonState instance.

Parameters:
buttons - an int value
Method Detail

get

public static MouseButtonState get(int buttons)
Get the MouseButtonState instance identified by mods. This method creates the MouseButtonState instance and caches it if it didn't already exist. Once created we won't need to create new MouseButtonState object instances each time a keyboard event occurs.

Parameters:
mods - valid button state (possibly OR'd together)
Returns:
The singleton MouseButtonState instance

buttonLeft

public boolean buttonLeft()
Get if the left mouse button is pressed

Returns:
if the left mouse button is pressed

buttonMiddle

public boolean buttonMiddle()
Get if the middle mouse button is pressed

Returns:
if the middle mouse button is pressed

buttonRight

public boolean buttonRight()
Get if the right mouse button is pressed

Returns:
if the middle mouse button is pressed

wheelUp

public boolean wheelUp()
Get if the wheel is up

Returns:
if the wheel is in the up

wheelDown

public boolean wheelDown()
Get if the wheel is down

Returns:
if the wheel is down

getState

public int getState()

button

final int button(int x)

toString

public java.lang.String toString()
Return a string represenation of this object

Overrides:
toString in class java.lang.Object
Returns:
a String represenation of this object